Recovery/Disconnection notification timing

0 votes

cocos2d-x SDK

I use Recovery like below.
_warpClientRef->setRecoveryAllowance(60);

When I use iPhone simulator, after connected, I turn off the network on my Mac, but onConnectDone wasn't called.
Then I turn on the network, onConnectDone was called, and I can recover.

But I have to inform user the network is lost at that time, not after network back.
How to achieve it?

Thanks a lot!

asked Mar 3, 2014 in AppWarp by joappdev (20 points)

2 Answers

0 votes
Hi Jo,

The sdk relies on the OS for pushing the network disconnected message. We've observed that different devices and simulators behave differently in terms of the time after which they inform the application of the network error. So the time after which the OS reports network loss is not defined - can you try on the device and see if the event is raised before you actually reconnect? It may take up to 20-30 seconds for it to detect after you've disconnected from your wifi network.
answered Mar 3, 2014 by dhruvc (1,099 points)
0 votes

iOS simulator

1. connect to server

2. turn off wifi on mac

3. wait more than 3 mins, no any notification from SDK

4. turn on wifi on mac

5. SDK said may recoverable, reconnect, fail to reconnect!

6. connect to server again, but refused by auth_error.

 

iPhone 5 ios7.0.6

1. connect to server via 3G

2. turn off 3G

3. wait more than 3 mins, no any notification from SDK

4. turn on 3G

5. wait more than 3 mins, didnt count precisely, but be sure very long.

    Suddenly SDK said may recoverable, reconnect, fail to reconnect!

6. connect to server again, but refused by auth_error.
 
 
Please help.
 
I wish that SDK can inform me at step3. as soon as possible.
Step 5. on device is too long for user, too.
Step 6. may be another issue if user really lost his network but wanna reconnect to game.
 
Is that better to use native SDK?
 
Thanks a lot!
answered Mar 3, 2014 by joappdev (20 points)
In our tests - if you use the native objective-C iOS SDK framework, it does detect the issue much faster. You can try it out. Also its something we will be investigating and will examine possible solutions to detect this case early in the C++ SDK as well.
How about wrap the native SDK to c++ interface?
Or change the BSD socket to iOS native socket in cocos2d-x SDK?

However I also target on android......
Hi - an update on this. We will be releasing a solution for this issue and deploying the patch on our servers on Monday (Mar 10). Also an SDK update will be made. The idea is to send application level keep alive messages between the client and server (heartbeat). It will reliably detect errors if heartbeats are missed and inform the application with an error callback in onConnectDone.
Great to hear that. Could you drop another comment when the SDK released?
Thanks so much!
https://github.com/shephertz/AppWarpCocos2DX/tree/master/V_1.6

The update will consume keep alive responses from the server and will report connection loss in a more reliable fashion. It should now take no more than 6 seconds for the application to get onConnectDone with error.

Please let us know once you've tried out the new version.
It seems not works.....
Once I change to V1.6, I can't get the onConnectionDone any more in the first place!

I'll try your sample project later......
It works now. New function is also OK!

That's because you changed the _status to private, and I have to use the getStatus() function.

Thanks
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
...