Пример #1
0
 def _sendRequest(self, ctx, callback, allowDelay = True):
     if ctx.isAuthorizationRequired() and not self.isLoggedOn():
         self.__waitingRequests.append((ctx,
          callback,
          ClanRequestResponse(ResponseCodes.AUTHENTIFICATION_ERROR, 'The user is not authorized.', None),
          allowDelay))
         self.login()
     else:
         self.clanSync(ctx)
         if self._clanCtrl and self._clanCtrl.simWGCGEnabled():
             result = yield super(ClanAvailableState, self)._sendRequest(ctx, allowDelay=allowDelay)
         else:
             result = ClanRequestResponse(ResponseCodes.WGCG_ERROR, 'Simulated WGCG error!', None)
         resultCode = result.code
         if resultCode == ResponseCodes.WGCG_ERROR:
             LOG_DEBUG('WGCG error has occurred! The state will be changed to NA.')
             self._changeState(ClanUnavailableState(self._clanCtrl))
             callback(result)
         elif ctx.getRequestType() != CLAN_REQUESTED_DATA_TYPE.LOGIN and resultCode == ResponseCodes.AUTHENTIFICATION_ERROR:
             LOG_WARNING('Request requires user to be authenticated. Will try to login and resend the request.', ctx)
             self.__waitingRequests.append((ctx,
              callback,
              result,
              allowDelay))
             self.login()
         else:
             callback(result)
     return
Пример #2
0
 def _sendRequest(self, ctx, callback, allowDelay = True):
     if ctx.getRequestType() == CLAN_REQUESTED_DATA_TYPE.PING:
         result = yield super(ClanUnavailableState, self)._sendRequest(ctx, allowDelay=allowDelay)
     else:
         result = ClanRequestResponse(ResponseCodes.WGCG_ERROR, 'WGCG is not available.', None)
     callback(result)
     return
Пример #3
0
 def _makeErrorResponse(self):
     return ClanRequestResponse(ResponseCodes.UNKNOWN_ERROR, 'Request cannot be sent from the current state', None)