How do I get the MatchID from the server once launched in Unreal Engine 4? I can see its passed in the session id and so, but how do I actually retrieve that? Thanks!
Assuming that you integrated the GSDK within your server, please refer to this section to learn about getting configuration settings within your game server:
For instance, to retrieve the session id, you can do the following:
auto it = config.find(Microsoft::Azure::Gaming::GSDK::SESSION_ID_KEY); if (it != config.end()) { std::string sessionId = config[Microsoft::Azure::Gaming::GSDK::SESSION_ID_KEY]; }
Please note that it’s only available after allocation (once readyForPlayers returns true).
Thank you! How can I know on the server when ready for players returns true? I want to get the info once I get the players joining the server as I want to know the final number of players going to the server.
Seems like I can call "getInitialPlayers();" on "playerConnected()", is this the correct way?
ReadyForPlayers will return true if the game server was allocated (clients are about to connect), please see the implementation here:
GetInitialPlayers is used to returns a list of the initial players that have access to this game server, used by PlayFab's Matchmaking offering after server allocation. To get the actual list of players connected to the server, you can use the following mechnism to add connected players into a list, and access it later on:
static private List<ConnectedPlayer> players = new List<ConnectedPlayer>(); static void OnPlayerConnected() { // When a new player connects, you can let PlayFab know by adding it to the vector of players and calling updateConnectedPlayers players.Add(new ConnectedPlayer("player_tag")); GameserverSDK.UpdateConnectedPlayers(players); }
4 People are following this question.