I need a way for a custom Server hosted with Playfab to read the changes on its own CustomData or its Tags.
Right now the only way to modify them is via Cloud Script called from a Client. After a GetCurrentGames() I read the CustomData and call the Cloud Script with the CustomData modified so the Cloud Script uses Server.SetGameServerInstanceData to update the value.
Any way I can read that CustomData (or Tags) in the Server instance? It could be a CloudScript function called from the server but I don't find a way to access that data besides the GetCurrentGames().
I actually plan to use a Tag in the server with the LobbyID so in the Client I can update the actual CustomData with a Tag filter in GetCurrentGames. It will be better if I there is a way to ask directly for the CustomData (or Tags) of a Server instance using its LobbyID.
Thanks for your amazing product, our game it's working great thanks to your hard work!
Answer by Brendan · Sep 06, 2017 at 07:22 AM
Actually, the recommended way to update the CustomData and Tags for a dedicated server would be for the server to call the appropriate Server API call. Is there a reason that's not an option in this case?
Yes, I want the user to add itself to a "waiting list" in the server, so that's why I'm using the CustomData and updating it from the client via Cloud Script. The plan is to be able to do a background matchmaking while the user is playing and connect to the match when enough people is waiting.
This is the process (if there is a better way to do it just tell me):
1. The client call GetCurrentGames() and selects a game to join (or creates one with Matchmake) but it doesn't get into the game yet, just saves its data.
2.The client adds itself to the waiting list in the server adding its ID to the CustomData on the server with a Cloud Script.
3. The client keeps updating the CustomData (using GetCurrentGames()) to see if there is enough players in the waiting list.
4. When the client sees enough players including itself he connects to the game. Once authenticated with the server, removes him from the waiting list.
What I'm looking for it's a way to read that values, from the server/cloud script and the client. I will love the server to watch for its CustomData and clean the waiting list and close if noone is waiting.
Thanks for your help, hope this clarifies a bit.
No, I really can't recommend that. What you're attempting to do is create a queued matchmaker using the CustomData for the servers themselves. As the calls in question are all web API based, there's a significant amount of latency involved. A matchmaker requires a dedicated server that maintains state information on all active games in-memory, so that it can quickly turn around match information to players authoritatively. Also, having every client hammering on the GetCurrentGames call would result in the title being throttled - the intended use case is that the client calls GetCurrentGames, picks a server, and joins it (potentially with one or two follow-up calls to the API, if joining the first server didn't work).
Okey Breandan, I understand the problem. I was trying to do it using just PlayFab. So what do you recommend for doing a queued matchmaker as you say? Would I need to do my own Matchmaker server to be able to store and manipulate properly the "waiting players" list?
Just one last question, is there any way to know the CustomData or Tags from the Server or Cloud Script having the LobbyID?
Since the server is the one setting the tags, what is the context in which it would also need to query its own tags? Or are you referring to your matchmaker? If it's the latter, what would it be using the custom data and tags to do?