WarpClient becomes inactive after change from 3G to WiFi or WiFi to 3G

0 votes
Hi,

When I change network state from either 3G to WiFi or WiFI to 3G my WarpClient just seems to stop working. No errors or anything but I if I try send a message in a chat room it never gets received, similarly if I try create a room it never gets added.

However, when I say client.getNetworkState() I still get returned 0 to say it is a success and I also still do have internet in my app because I have a map and that continues to work even on unloaded areas so there is definitely a connection.

I am using Connection resilliency and it works in keeping a connection alive when I have no internet at all i.e. no wifi or 3G but not for swapping between the two.

What is the issue here? Do I need to somehow refresh the client or something?
asked Jul 30, 2015 in AppWarp by Kiaan Pillay (20 points)
Which SDK exactly you are using? So we can trace it out on our side.
I am using the AppWarp42MultiplayerGamingSDK
Can you please also share platform by which you are building app like unity/Android/iOS...
Oh of course! Silly thing to leave out. It is an Android app
Thanks, actually you can build android app using unity/corona/cocos2d/phoneGap/libgdx. So that is the concern behind that. We will validate it on our end and revert to you.

1 Answer

0 votes

Hi,

If you are using connection resiliencyfeature. So you have already set the recovery allowance using below API.

warpClient.setRecoveryAllowance(60);

So when you switched to a network first you will get connection error with the result code 5 as internet is gone. And when switching is completed you will get CONNECTION_ERROR_RECOVERABLE as result code 9. in that case you have to call recover connection API like :

    if(arg0.getResult() == WarpResponseResultCode.CONNECTION_ERROR_RECOVERABLE){
            // yay! we are connected to Warp server
            warpClient.RecoverConnection()
        }  

Let me know if it helps.

Thanks & Regards

Vishnu Garg

answered Jul 30, 2015 by Vishnu Garg (674 points)
@Override
    public void onConnectDone(final ConnectEvent event) {
        Log.d("Logger", "CD");
        handler.post(new Runnable() {
            @Override
            public void run() {
             
                if (event.getResult() == WarpResponseResultCode.SUCCESS) {
                    Log.d("Logger", "Connection success");
                } else if (event.getResult() == WarpResponseResultCode.SUCCESS_RECOVERED) {
                    Log.d("Logger", "Connection recovered");
                } else if (event.getResult() == WarpResponseResultCode.CONNECTION_ERROR_RECOVERABLE) {
                    Log.d("Logger", "Recoverable in 5");
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            //    progressDialog = ProgressDialog.show(ChatActivity.this, "", "Recovering...");
                            theClient.RecoverConnection();
                        }
                    }, 5000);
                } else {
                    Log.d("Logger", "Non rec, reconnecting");
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            // progressDialog = ProgressDialog.show(ChatActivity.this, "", "Reconnecting...");
                            theClient.connectWithUserName(Utils.USER_NAME);
                        }
                    }, 5000);
                }
            }
        });
    }
In this code else block called always once your connection goes and it can be in a loop so avoid the else block theClient.connectWithUserName(Utils.USER_NAME);
in onConnectDone function.

As I explained earlier whenever you switch you got connection error and according to your code it again try to reconnect so again and again same thing happens.
Are you saying I should just remove the else? Please show me by means of the actual code... thank you so much you have been so helpful throughout
Yes, Will you try it after removing the else cause because whenever you are switching connectivity you will get connection error and it goes in loop.
Hey, no difference when I take it out unfortunately.
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
...