How to disconnect a player if he gets banned on Playfab while connected to game?
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
How to disconnect a player if he gets banned on Playfab while connected to game?
J_Skowol
2020-08-18 16:40:05
I'm developing a multiplayer game using Photon Realtime and Playfab, and I've made the custom authentication with playfab to prevent users connecting to the game with no authentication.
This way, if a player is banned on Playfab, he won't be able to login to the game anymore, because he won't have the authentication token required to start photon client (unless if he uses a different account and a different IP address),
But if the player is already connected to the game when the banning on Playfab happens, he won't get kicked out of the photon session and will still be able to play untill the moment he logs out. Is there a way to prevent this, so that his photon client would immediately (or shortly after) get the state "Error" and disconnected from the session?
Comments
Authentication values are usually cached for a reasonable time to avoid having to sync potentially millions of small changes across a wide range of services.
Your app can talk to the Playfab service anytime you want. If that says the user is banned, simply disconnect from Photon, too.
If some hacker would prevent this disconnect, the user can stay online until the next time authentication is done (on the Name Server, when the client connects).
Thank you for your answer. The hacker preventing the disconnect on the client side was exactly my concern, so I was wondering if there was a way to trigger this action on the server.
Have a look at this page about Hacking Counters:
https://doc.photonengine.com/en-us/pun/current/gameplay/hackingprotection
If you build a plugin, you can disconnect users (but have to make sure nobody else does).
You should use an account system which can ban users via authentication. Else, the hacker will simply reconnect.