question

nikosp420 avatar image
nikosp420 asked

How to check if client is connected to the services?

So i have implemented login and leaderboard but i cannot understand how client checks if it is connected to services.

I already tried to make multiple calls on ConnectToServices() method that is simply a PlayFabClientAPI.LoginWithPlayFab() and put a bool inside.

But if he is connected i cannot make the bool to false if he disconnects. I tried some things to recreate the disconnection and when i called API gave me an ExceptionError to connect to services.

So is there a way to check if there is a connection Client<->Service

Or is it possible to not trigger the ExceptionError and to Trigger a ConnectToServices() ?

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

·
Seth Du avatar image
Seth Du answered

PlayFab is a service based on RESTful API, which is stateless. By default, there is no native feature that can directly indicate the state of the player. After the login, a session ticket and entity token will be generated, whose expiration time will be around 24 hours. As long as they are not expired, players can use it to access PlayFab service via Client API calls.

The work around solution is indicating the state information by storing data on Player data. There should be background service for the game client so that after the client is in background for some time, UpdateUserData API will be called to update the state information.

In addition, if you are paid tier users, you can access the party feature of PlayFab: https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/networking/. Because it is real-time, it will be easier to maintain the online state of the players.

10 |1200

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

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.