Noam Sapir avatar image
Noam Sapir asked

Disconnect old connection when new login detected from the same user

I'm developing Virtual world and i'm trying to add a function to prevent users from login in more than once.

I want create a system that will detect new login that has been connected from the same user, when the player connects again to the game his old connection will disconnect automatically.

How this supposed to look:

I'm playing the game in Client 1, My username = Name

When Username "Name" connects again (As Client 2) to the game in the new client

Disconnect the old Client 1 connection, Keep the new connection on Client 2.

I saw some other games that added this function (Like the game they also using Playfab).

I'm wondering how can i add this function.

also i saw this post:

I think its too complex to add, I don't really want to make automatic checks every 2 minutes or so to see if the player is connected or not.

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

The workaround that you mentioned is still the way to achieve single-screen login with PlayFab. Currently, there are no updates about the feature about single-screen login. There is no ETA.

PlayFab provides REST API for users to log in to the backend. It returns session tickets that expired after 24 hours. When Players invoke our client API, the session tickets would be contained to the http request headers as the credentials. It’s a stateless short connection. So our API end-points can’t “disconnect” from the player like a “long connection”. So, currently, we can only request the data regularly, clear the local cache according to the returned result.

You can keep an eye on our blog for the latest updates of PlayFab features.

10 |1200

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

Noam Sapir avatar image Noam Sapir commented ·

Thank you for your help,
But I didn't really understood it,
Do you know how those games implemented single screen login? i really need to add this feature. I cannot wait years for this feature to be added officially to Playfab.

I made something that "works":

When player logins i'm generating custom number and saving it on player data + On local client as String,

When the player login again its generates a new custom number again and saves it,

Every x seconds the client loads the data from Playfab and compares the numbers, If the local client number not equals to the new loaded number, the player disconnects.

This kind of working but the problem is that i don't want to load the data every x time.

I want to run this function automatically like when a new login has been detected.

For example i saw on Automation Rules function called "On player login". My idea is when this Rule detects a new login, it will automatically call the function in Unity for the clients (The same user) to compare the numbers.

Do you think this can work?, The Automation should detect automatically connection and send as CloudS the results to the client without request from the client.

Or there is a simple way to do that?

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Noam Sapir commented ·

Generally, if that game is a multiplayer online game, it is likely to have an authorization server. If they have a custom server, they are able to send the message from the server to the client.

PlayFab doesn't support sending the message or other things from the PlayFab main server to clients. The client's request is required.

Your solution is also suitable for the custom server, but can't be implemented by CloudScript. If you have a custom server, you can establish a long connection between the server and the client. Then you can send messages from the server-side to the clients.

1 Like 1 ·
Noam Sapir avatar image Noam Sapir Sarah Zhang commented ·

Thank you! :)

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.