Cocos2d-x how to reconnect without resilience

0 votes
Hi

our app uses appwarp cocos2d-x sdk and we are not using auto reconnection because we wanna know the disconnection immediately and maually reconnect.

But sometimes it couldn't reconnect again and no response. It happened on android devices more (less on iOS). Usually happened when multiple devices connected to the same Wifi Env. The internet bandwidth should not be the problem. The 3G/4G mobile network is more stable.

I would like to confirm the sequences of app call after onconnectdone indicates error

Should I call disconnect or terminate first? Then connect? Or simply connect? Multiple connect() calls safe?

Is that possible that onconnectdone doesn't report error? or it there a timeout of connection? Should I setup a watchdog by myself.

It's not very easy to replicate so I just wanna confirm the behavior first...

Thanks a lot.

 

Jo
asked Jul 31, 2015 in AppWarp by joappdev (20 points)
edited Jul 31, 2015 by joappdev

1 Answer

0 votes
Hi Jo,

Whenever any client looses connection, SDK waits for continuous 3 sendKeepAlive events to fail. After that it assumes the disconnection and fires onConnectDone with proper error code, in your case it will be connection_error.

If user is idle after connecting to AppWarp server then SDK sends keepAlive message to the server after every 2 seconds to tell the server, "Hey, I am alive". If sever does not receives continuous 3 keepAlives for an idle user it assumes that client is disconnected and it acts accordingly to that particular user and notify others if any.

After you receive connection_error, then you can call connect method to start a new session with server if you are not using Connection resiliency.

Please check your code as per the above explanation. If problem continues, can you please share AppWarp related code snippets or any sample where i can replicate the issue on support@shephertz.com?

Thanks.
answered Jul 31, 2015 by rajeev.etc (1,660 points)
https://dl.dropboxusercontent.com/u/160381966/AppWarpCocos2DX-master-ModifyByJo.zip

I modified the sample project as how I used in my project.
"After onConnectionDone Error, I call connect function."
And I tested it on the iPhone device.
In addition I used the iPhone developer options (in the setting) to simulate bad network. The results are:
1. After I connect again, sometimes it stays on connecting state for a long time (may be over 60 secs) .
2. After 1., usually it comes back, but sometimes it can't come back which is keeping on the connecting state even if the network return to normal. (Android happens easily on my app)
3. and then the app cannot do anything because of connecting state. It's not easy to reproduce it but it did happen on my app and this sample project.

-----
a) I would like to ask a quick solution of this situation, because the app released is facing this issue. How to break the connecting state and make it restart over manually? I may use a  timer as watchdog.
b) Please take a look of the project I attached, and correct the way I use the SDK.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...