Sign In Register

How can we help you today?

Start a new topic
Answered

Responses binding for AuthenticatedConnectResponse

 I know we don't have it in the responses binding, but is there a workaround? I need to do some stuff everytime a user reconnects to the game using AuthenticatedConnectRequest.


Best Answer

Ah, you want to know when a player connects on the server?


If so, there is a script executed when a player connects. It's in System -> Player Connected


You can bind and Action<string> to the authenticated event, this will be fired once AuthenticatedConnectRequest completes and the session is authenticated


GS.GameSparksAuthenticated = (playerId) => { 

    //Your code here

};


Gabriel

There's no server side workaround is there?

 

Answer

Ah, you want to know when a player connects on the server?


If so, there is a script executed when a player connects. It's in System -> Player Connected

Cool. Did not know it was there. Thank you.

 

Hi,

     I use System -> Player connected to add my player to a table. I would like to remove this player when it disconnects. I try to use System -> Player disconnected, but I don't know how to test it.

Hi Elizabeth,


You can do this a few ways, you could send an EndSessionRequest in the Test Harness which when sent would execute whatever code is located in PlayerDisconnected. You can also disconnect a player in Cloud Code which you can read about here. Probably the best way to test it would be to create an event called something like "testPlayerDisconnected", pop any code you want to run when a player disconnects in there and run it manually from the Test Harness, the advantage here is that the debugger will pop up and step through your code so you can spot any problems easily, once it's all working and you're happy with it you can place it in the PlayerDisconnect System Script. If you have anymore questions just let me know.


Thanks,

Liam

Hi Liam,


Does the server wait for the Player Connected script to finish running before sending the AuthenticatedConnectResponse to the client?

Also, when does the Player Disconnected script run - after EndSessionRequest is sent, and after a period of inactivity?


Hi Baris. 


Yes, the server waits player connected script to finish. 


Player Disconnected only runs when the player actually disconnects the socket it doesn’t run with EndSessionRequest. 


Regards, Patrick. 



Login to post a comment