Sign In Register

How can we help you today?

Start a new topic
Answered

c++ SDK, iOS enter background, but the online status of the player in server is still true

Hi

I tried cocos2d-x c++ sdks in iOS simulator.

I found if I pressed the home button let app go to background, the online status of the player in server is still true.


1. Is that normal? Will app keep receive data in the background?

I think the cocos2d-x update function would stop, so the SDK should not be working.

And then the server should time-out the player and set the online status to false.


2. Can I manually disconnect when app goes to background?


I need to send push notification if players are not in foreground, please help.

Thanks a lot


Jo


Best Answer

 Hi Jo

You can use GS.Disconnect when the app goes into the background and GS.Connect when it comes into the foreground

SetDurable can be used to queue  messages and request  to get sent when the player reconnects.


Thanks

Katie


 Hi Jo


1 - Yes if the websocket doesn't close properly they player can appear online for a while after.

  Gamesparks will disconnect when in the background and reconnect when the app is opened.

2. To manually disconnect the player use Spark.getPlayer().disconnect(true);


Thanks

Katie

Hi Katie


1. "Gamesparks will disconnect when in the background and reconnect when the app is opened."

    How long will it timeout? is that possible to shorten it to few seconds? 

    Because of it, I cannot use the "player disconnected" binding cloud code in this situation.

    And users will miss some messages because push notification won't be sent.


2. What you mentioned is cloud code api? But I'm using cocos2d-x c++ SDK.

    For the server, it still thinks the player is online BTW.


Thanks a lot.

Jo


Answer

 Hi Jo

You can use GS.Disconnect when the app goes into the background and GS.Connect when it comes into the foreground

SetDurable can be used to queue  messages and request  to get sent when the player reconnects.


Thanks

Katie

Login to post a comment