Appwarp-Close Application Using Home Button in Android

0 votes
Hi All I asked this question but I got no answer from developer. So, I am asking again. When I close my application from in game menu(I call Disconnect API while closing) and restart application, appwarp connects succesfully. But when I close application using hardware home button and restart application, It returns me 1 error. And after some time, it connects. How can I solve this problem in unity? In my previous question, developer says I suggest call Disconnect API before application quit. I already do it. As I said it does not work while quit using home button. Can someone from shephertz can try this on android device and return me? Thanks
asked Aug 31, 2016 in Unity by gokhan (20 points)

1 Answer

0 votes
 
Best answer
Hello Gokhan,

Could you please provide following info regarding this issue:

 - Did you kill the app from background as well to after pressing the home button to get this issue

 - After how much time you are reopening the app

 - Are you using connection-resiliency in this app

It will help us to understand the issue so that we can suggest you better way for the same.

Regards,

Rajeev
answered Sep 1, 2016 by rajeev.etc (1,660 points)
selected Sep 27, 2016 by gokhan
Hi Rajeev
-Yeah I kill the game from background. I press HW home button then after I close application.
-Immediately I open application. If I wait lets say 1 or 2 minute and after I open application, it connects successfully.
-Yeah I tested and it happens when I use setRecoveryAllowance(120). If I remove that line no problem.
I am waiting from you
Thanks Rajeev
Hi Gokhan,

This is happening because when you kill the app from background then all the live instances of the socket got destroyed but the session for the user is paused for 120 sec on the server as you are using connection-resiliency. Once the 120 sec is passed after disconnection then you will be able to connect.

The solution to this problem is calling recoverConnectionWithSessionId API(http://appwarp.shephertz.com/game-development-center/csharp-api-reference/#recoverconnectionwithsessionid). It will recover the session if this api is called within the 120 sec of disconnection and this fails then you call connect API.

To call this API, you need to get the sessionID using getSessionID API(http://appwarp.shephertz.com/game-development-center/csharp-api-reference/#getsessionid) just after you successfully get connected to the AppWarp server. You have to save this session id in the player prefs. When you reopen the app then you need to get the session id from player prefs and call recoverConnectionWithSessionID API.

Let me know if you have any further queries.

Regards,
Rajeev
Hi Rajeev
Thanks for quick response. So What I understood is that: when application opens, I use recoverconnectionwithsessionid api, if it fails(it means 120 sec passed), I will use connect api right?
Another thing is that I triend to reduce 120 seconds to 10 second. And my problem gone. But can this cause connection recovery problems?
Hi Gokhan,

Yes, after 120 secs, the recoverConnection calls will be denied by the server for that user and you will have to call connect api.

Reducing recoveryAllowanceTime from 120 secs to 10 secs tells the server that hold the user session for 10 secs and if user does not call recoverConnection/recoverConnectionWithSessionID APIs within the 10 secs of time frame after disconnection then delete the user session. As a result of which, the user will not be able to recover the session after 10 secs of disconnection.

It is recommended to have the recoveryAllowanceTime within 30 secs to 60 secs for real time multiplayer games.

Let me know if you have any further queries.

Regards,
Rajeev
Thanks Rajeev. Most probably my problem solved. What I am doing is: when application is opened, firstly I call Connect API. If it returns me 1 error code, I call recoverconnectionwithsessionid api. Then it recovers connection.
Thanks again
Great to know that your problem has been resolved now. If possible, please accept the answer so that it will help others in the community to find the right answer if facing the same problem.
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
...