recoverConnectionWithSessionID Issue in Corona SDK

0 votes
local appWarpClient = require "AppWarp.WarpClient"
local sqlModule = require( "module.SQL_Module" )
 
local warpConnect = {
timeout = 180,
apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
secretKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
 
function warpConnect:onConnectDone( resultCode, reasonCode )
 
if resultCode == WarpResponseResultCode.SUCCESS then
     local ssID = sqlModule.GID() -- get SessionID from Sqlite
     if ssID.ssid == nil then
          local appSID= appWarpClient.getSessionID()
          sqlModule.insertSessionID( {ssid=tostring(appSID)} )
      end
else
      sqlModule.nullSessionID() -- reset SessonID to NULL
      appWarpClient.disconnect()
      warpConnect:connectToServer()
end
 
function warpConnect:connectToServer()
 
     local ssID = sqlModule.GID() -- get SessonID from Sqlite
     if ssID.ssid == nil then
          print( "newConnection")
          appWarpClient.connectWithUserName("464432ggfdv")
     else
          print( "reConnection")
          appWarpClient.recoverConnectionWithSessionID( tonumber(ssID.ssid), "464432ggfdv")
     end
 
     appWarpClient.addRequestListener("onConnectDone", self.onConnectDone)
 
end
 
function warpConnect:init()
 
     appWarpClient.setRecoveryAllowance(self.timeout)
 
     appWarpClient.initialize( self.apiKey, self.secretKey)
 
     local function gameLoop(event)
          appWarpClient.Loop()
     end
     Runtime:addEventListener("enterFrame", gameLoop)
 
     warpConnect:connectToServer()
end
 
============================================================
at first, thx for answer my Q
 
we are using appwarp in our project
 
when we try to use recoverConnectionWithSessionID to recover connection....
 
we recieve resultCode 21 ususlly...
 
and somtimes appWarpClient.getSessionID() will get "nil" or "0"
 
have any one can help me to understand... what happen...
 
 
 
asked Jul 27, 2015 in AppWarp by ric1029 (10 points)

1 Answer

0 votes

Hi,

Recover Connection is introduce basically in cases where

  • While playing a game your internet connection is gone and after some seconds it will resume.
  • Player either disconneted due to some reason.

In this case when player reconnected without making a call on AppWarp, player will get a call Back in onConnectDone function

as a result code Connection_Error_Recoverable in this case you have to call recoverConnection API.

After going through with your code snippet you are first disconnecting the player and want to do recover connection while connecting.Recover connection won't work when you call disconnect API.

appWarpClient.disconnect()

 warpConnect:connectToServer()
Please call recoverConnectionWithSessionID only when you get a result code Connection_Error_Recoverable.
 
Let me know if it helps.
 
Thanks & Regards
Vishnu Garg
answered Jul 28, 2015 by Vishnu Garg (674 points)
thank you for your comment

and let me more understand how is it work

but we still have some issues

when user kill APP and re-open APP immediately

they try to reconnect to appWarp Server using connectWithUserName()

at this time, they got a result Code 21 and getSessionID() will be return nil

how to make user reconnect to session as they use last time

thank you for your help
For recovery you have to call setRecoveryAllowance in which you can set recovery time.
could you tell me what's the result Code 21 in onConnectDone
So its a basically reasonCode denotes WAITING_FOR_PAUSED_USER and it comes when you will receive  responseResultCode as WarpResponseResultCode.AUTH_ERROR  in onConnectDone callBack.
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
...