Beispiel #1
0
 def __doLogin(self, callback):
     if not LOGIN_STATE.canDoLogin(self.__loginState):
         callback(self.isLoggedOn())
         return
     LOG_DEBUG('Clan gate login processing...')
     self.__loginState = LOGIN_STATE.LOGGING_IN
     nextLoginState = LOGIN_STATE.LOGGED_OFF
     LOG_DEBUG('Requesting spa token...')
     response = yield self._tokenRequester.request()
     if response and response.isValid():
         pDbID = getPlayerDatabaseID()
         if response.getDatabaseID() == pDbID:
             LOG_DEBUG('Trying to login to the clan lib...')
             result = yield self.sendRequest(contexts.LogInCtx(pDbID, response.getToken()))
             if result.isSuccess():
                 nextLoginState = LOGIN_STATE.LOGGED_ON
             else:
                 nextLoginState = LOGIN_STATE.LOGGED_OFF
     else:
         LOG_WARNING('There is error while getting spa token for clan gate', response)
     self.__loginState = nextLoginState
     if self.isLoggedOn():
         self._clanCtrl.onStateUpdated()
     self.__processWaitingRequests()
     callback(self.isLoggedOn())
Beispiel #2
0
 def __doLogin(self, callback):
     if not LOGIN_STATE.canDoLogin(self.__loginState):
         callback(self.isLoggedOn())
         return
     LOG_DEBUG('Clan gate login processing...')
     self.__loginState = LOGIN_STATE.LOGGING_IN
     nextLoginState = LOGIN_STATE.LOGGED_OFF
     LOG_DEBUG('Requesting spa token...')
     response = yield self._tokenRequester.request()
     if response and response.isValid():
         pDbID = getPlayerDatabaseID()
         if response.getDatabaseID() == pDbID:
             LOG_DEBUG('Trying to login to the clan lib...')
             result = yield self.sendRequest(
                 contexts.LogInCtx(pDbID, response.getToken()))
             if result.isSuccess():
                 nextLoginState = LOGIN_STATE.LOGGED_ON
             else:
                 nextLoginState = LOGIN_STATE.LOGGED_OFF
     else:
         LOG_WARNING('There is error while getting spa token for clan gate',
                     response)
     self.__loginState = nextLoginState
     if self.isLoggedOn():
         self._clanCtrl.onStateUpdated()
     self.__processWaitingRequests()
     callback(self.isLoggedOn())
Beispiel #3
0
 def __doLogin(self, callback):
     if not LOGIN_STATE.canDoLogin(self.__loginState):
         callback(self.isLoggedOn())
         return
     LOG_DEBUG('Wgcg gate login processing...')
     self.__loginState = LOGIN_STATE.LOGGING_IN
     nextLoginState = LOGIN_STATE.LOGGED_OFF
     LOG_DEBUG('Requesting spa token...')
     response = yield self._tokenRequester.request(allowDelay=True)
     if response and response.isValid():
         pDbID = getPlayerDatabaseID()
         if response.getDatabaseID() == pDbID:
             LOG_DEBUG('Trying to login to the wgcg lib...')
             responseTime = time_utils.getServerUTCTime()
             result = yield self.sendRequest(
                 LogInCtx(pDbID, response.getToken()))
             if result.isSuccess():
                 nextLoginState = LOGIN_STATE.LOGGED_ON
                 data = result.getData()
                 self.__accessTokenData = AccessTokenData(
                     data['access_token'],
                     responseTime + float(data['expires_in']))
             else:
                 nextLoginState = LOGIN_STATE.LOGGED_OFF
     else:
         LOG_WARNING('There is error while getting spa token for wgcg gate',
                     response)
     self.__loginState = nextLoginState
     self.__clanSync = False
     self.__processWaitingRequests()
     callback(self.isLoggedOn())
Beispiel #4
0
 def __doLogin(self, callback):
     if not LOGIN_STATE.canDoLogin(self.__loginState):
         callback(self.isLoggedOn())
         return
     else:
         self.__accessTokenData = None
         LOG_DEBUG('Clan gate login processing...')
         self.__loginState = LOGIN_STATE.LOGGING_IN
         nextLoginState = LOGIN_STATE.LOGGED_OFF
         LOG_DEBUG('Requesting spa token...')
         response = yield self._tokenRequester.request(allowDelay=True)
         if response and response.isValid():
             pDbID = getPlayerDatabaseID()
             if response.getDatabaseID() == pDbID:
                 LOG_DEBUG('Trying to login to the clan lib...')
                 responseTime = time_utils.getCurrentTimestamp()
                 result = yield self.sendRequest(contexts.LogInCtx(pDbID, response.getToken()))
                 if result.isSuccess():
                     nextLoginState = LOGIN_STATE.LOGGED_ON
                     data = result.getData()
                     accessToken = data.get(_FIELD_ACCESS_TOKEN, None)
                     if accessToken is not None:
                         expiresIn = data.get(_FIELD_EXPIRES_IN, 0)
                         if expiresIn is None:
                             LOG_WARNING('Login success but ExpiresIn not defined! Use default value == 0!')
                         else:
                             responseTime += float(expiresIn)
                         self.__accessTokenData = AccessTokenData(accessToken, responseTime)
                     else:
                         LOG_WARNING('Login success but AccessToken not defined!')
                 else:
                     nextLoginState = LOGIN_STATE.LOGGED_OFF
         else:
             LOG_WARNING('There is error while getting spa token for clan gate', response)
         self.__loginState = nextLoginState
         self.__clanSync = False
         self.__processWaitingRequests()
         callback(self.isLoggedOn())
         return