question

DANIEL MARQUES PEREIRA avatar image
DANIEL MARQUES PEREIRA asked

So how do I know a user got Offline?

Is there anyway I can know when a player got offline?

I want to notify his/her friends when he/she got offline, so they cannot be invited to a play together anymore

Player DataFriends
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

·
Sarah Zhang avatar image
Sarah Zhang answered

Firstly, the login mechanism that PlayFab provides is stateless. Server-side won’t remember the user's login information. So, we can’t get the state that client’s online or offline. So we should use an external server-side mechanism to handle the online and offline state.

Secondly, there is no built-in API to share info between friends, group data only suits less than a dozen or so players and polling Player public data will over frequency limits, they are not very suitable for such cases.

Hence, a possible workaround is to make a custom server to handle the players’ if-online state. PlayFab provides the server hosting service Multiplayer Server 2.0, it is available to PlayFab indie, pro, and enterprise-tier customers. Use this service you can host your custom server executable on the PlayFab.

You can implement a basic forwarding server. Let the clients establish a long connection with it when they log in. Use a heartbeats mechanism to detect client connection status then broadcast to every client who connects with it. All in all, you need to build a simple server-side program by yourself to implement the feature you want.

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.