Sign In Register

How can we help you today?

Start a new topic
Answered

"online": true-->does it actually indicate current status?

i am ruinning this code:

 

 var players = Spark.systemCollection("player");
 
var playesOnline = players.find({"online" : true}, {_id : 1, displayName:1,location:1,userName:1,online:1}); // requires an 'email' value to be set on each player via setScriptData, and an index to exist on scriptData.email
       
  Spark.setScriptData("playesOnline", playesOnline);

 but it is returinnning me list which contains players that are not actually online. 
so the big question is what actually represents by  "online" : true




Best Answer

Hi Ashan, 


GS.Disconnect() should be what you are looking for. This will disconnect the player and immediately set their status as offline. This can bee seen in the Test Harness if you Authenticate a player, click on disconnect at the top of the harness and check their "isOnline" status inside their entry in the System.Player Collection.


EndSession is for Analytics purposes and determining session length on the platform. 

Happy to help - Patrick. 


Hi Ahsan,


Would these players have logged in within the last half hour or so of running that script? Can I confirm that you are ending the players session with EndSessionRequest (https://docs.gamesparks.com/api-documentation/request-api/analytics/endsessionrequest.html) what might be the case here is, if this request isn't sent it can take a bit of time for the session to timeout and update the player online status. This will also help in accurately determining the players session length. I hope this helps answer your question. 


Kind regards,

 - Steve

hi. I am back again to this issue. it is still unsolved.
i am just calling disConnect() to end the game.

should i call LogOut() or  EndSessionRequest() ??

which one would be better during logout and shutdown also?

Answer

Hi Ashan, 


GS.Disconnect() should be what you are looking for. This will disconnect the player and immediately set their status as offline. This can bee seen in the Test Harness if you Authenticate a player, click on disconnect at the top of the harness and check their "isOnline" status inside their entry in the System.Player Collection.


EndSession is for Analytics purposes and determining session length on the platform. 

Happy to help - Patrick. 

Login to post a comment