question

rob avatar image
rob asked

GameServerState not returned in GetCurrentGames?

Hi,

I'm using GetCurrentGames to show a list of games. I want players to be able to make their games private and I was under the impression I could do this using SetGameServerInstanceState, setting the state to Closed.

This removes the game from matchmaking but it doesn't remove it from GetCurrentGames. That's fine as long as I can read the state from the returned GameInfo object which should be possible according to the docs but it doesn't seem to be there in reality.

PlayFabClientAPI.GetCurrentGames(request, (result) =>
{
	foreach (GameInfo gameInfo in result.Games)
	{
		Debug.Log("Game state: " + gameInfo.GameServerState);//prints 'Game state:' no matter what the value of GameServerState according to the server
	}
}
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Correct - GetCurrentGames is intended to provide info on all active games, whether they are available for matchmaking or not. The issue is that the docs aren't up-to-date, so I'm opening a bug on that. If you check the actual response coming back from the GetCurrentGames call, you'll see that there are two values passed back for the server state - GameServerState, which is an integer value, and GameServerStateEnum, which is a string. It looks like the enum is what you'll want to use, in this case. If you're not seeing that, can you provide us with the details (Title ID, build ID, when you last attempted this, and what the details are of the response you got back from the call to GetCurrentGames)?

4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

rob avatar image rob commented ·

Ok interesting, it looks like that update hasn't reached the Unity SDK yet. I've just grabbed the latest version and GameServerStateEnum doesn't exist. I checked the API request at https://api.playfab.com/documentation/client/method/GetCurrentGames using the 'Try it' feature and it works fine on there and returns the correct state, I just can't access that in Unity.

0 Likes 0 ·
rob avatar image rob commented ·

So do I just need to wait for an update to the SDK? Is this a recognised issue that will be fixed?

0 Likes 0 ·
brendan avatar image brendan rob commented ·

It looks like the SDK hasn't been updated since that change was made, so I'll ask the tools team to update early next week. Meanwhile, you can make the change your self, directly. Just add this to the GameInfo definition:

public GameInstanceState? GameServerStateEnum;
0 Likes 0 ·
rob avatar image rob brendan commented ·

Perfect, that works, thanks.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.