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