Sign In Register

How can we help you today?

Start a new topic

Player connect / disconnect events


I am actually working on a turn based game with Unity (2 to 6 players) and I would like to know when a player disconnects from a Challenge. I have tried to intercept the event GS_PLAYER_DISCONNECT (under System) but nothings happend. Same for the GS_PLAYER_CONNECT. But simple Events and Challenge Events works like a charm.


I didn't succeed understand exactly in what conditions those events are

triggered ... I read that they are sended automatically but i never receive them.


Can you help me to understand their conditions of use ?


Thanks !

1 Comment

Hi Dylan HC,

GS_PLAYER_DISCONNECT and GS_PLAYER_CONNECT are automatically triggered when a player connects/ disconnects to Gamesparks. To check if they are being called you can use Spark.getLog().debug("Player disconnected " + Spark.getPlayer().getUserName()); in the GS_PLAYER_DISCONNECT script and check your script.logs to see which player gets disconnected. Your script.logs can be found under Data Explorer > collections > runtime > script.log. Note if there is an unclean disconnect (i.e. players internet disconnects)  there can be a delay of up to 30 minutes before it is triggered this is because the websocket will remain open for a period of time. This can be fixed by using Spark.getPlayer().Disconnect(true) in the Authentication response which clears any open sessions except the current one.

I hope this helps if you have any other questions let us know.



Login to post a comment