def _execResponse(idTypeList): global _CHAIN_CB_ID if _CHAIN_CB_ID is not None: BigWorld.cancelCallback(_CHAIN_CB_ID) _CHAIN_CB_ID = None LOG_DEBUG('Executing package from chain, id: {0}'.format(idTypeList[0][0])) from exchangeapi.AdapterUtils import getAdapter getAdapter('IResponse', ['response']).delete(None, None, idTypeList) return
def ifaceDataCallback(callback, op, code, servResponseOb): servResponseOb = compactDescriptorToResponse(servResponseOb) headers = servResponseOb[0] responseId = headers[2] if responseId not in _RESPONSE_CALLBACKS: _RESPONSE_CALLBACKS[responseId] = callback from exchangeapi.AdapterUtils import getAdapter getAdapter('IResponse', ['response']).add(None, None, {'data': servResponseOb}, idTypeList=[[responseId, 'response']]) return
def onBattleResultShort(event): player = BigWorld.player() for team in event.ob['teams'].itervalues(): for member in team.itervalues(): if member['id'] == event.ob['playerID']: for planeStats in member['planes']: player.responseSender([[planeStats['planeID'], 'plane']], 'IExperience', {}, SUCCESS) break getAdapter('IBattleResultShort', [event.idTypeList[0][1]]).add(None, None, event.ob, reportID=event.idTypeList[0][0]) return
def responseDeleted(event): global _CHAIN_CB_ID from exchangeapi.AdapterUtils import getAdapter rid = event.idTypeList[0][0] getAdapter('ILastProcessedResponse', ['account']).edit(None, None, EMPTY_IDTYPELIST, {'rid': rid}) if rid == MAX_SENT_PKG_COUNT: rid = 1 else: rid += 1 LOG_DEBUG('Setting callback for package id: {0}'.format(rid)) _CHAIN_CB_ID = BigWorld.callback( 0, partial(_execResponse, [[rid, 'response']])) return
def delete(self, account, requestID, idTypeList, **kw): from exchangeapi.AdapterUtils import getAdapter self.add(None, None, getAdapter(self._ifacename, ['account']).view(None, None, EMPTY_IDTYPELIST), idTypeList=idTypeList) return
def processIFaceData(headers, respdata): for data, idTypeList in respdata: typeList = splitIDTypeList(idTypeList)[1] for ifacename in data: if data[ifacename] and not headers[0] == int( IS_CLIENT) and getOblocation( ifacename, typeList) == OB_LOCATION.MIXED: data[ifacename] = getAdapter(ifacename, typeList, silent=True)( getPlayer(), data[ifacename], idTypeList=idTypeList) ob = [headers, respdata, ErrorCodes.SUCCESS] debug_observable.IfaceDebugOutput(COMMAND_TYPES.RESPONSE, ob=ob)
def processBaseItem(idTypeList, ifacename, data): from exchangeapi.AdapterUtils import getAdapter from exchangeapi.Connectors import getObject idList, typeList = splitIDTypeList(idTypeList) adapter = getAdapter(ifacename, typeList) ob = getattr(adapter, request.method)( account=account, data=data, requestID=requestID, initByServer=initByServer, idTypeList=idTypeList, ob=OBJECTS.setdefault(idFromList(typeList), {}).setdefault( idFromList(idList), getObject( idTypeList, account))) if adapter else None return (ob, adapter)
def startPackageChain(): global _startQueried global _CHAIN_CB_ID _startQueried = True if not _movieInited: return elif _CHAIN_CB_ID is not None: return else: from exchangeapi.AdapterUtils import getAdapter lastResponse = getAdapter('ILastProcessedResponse', ['account'])(None, None) rid = lastResponse['rid'] + 1 LOG_DEBUG( 'Starting package chain, setting callback for package id: {0}'. format(rid)) _execResponse([[rid, 'response']]) return
def responseAdded(event): from exchangeapi.AdapterUtils import getAdapter lastResponse = getAdapter('ILastProcessedResponse', ['account'])(None, None) currentId = event.idTypeList[0][0] if lastResponse['rid'] + 1 != currentId and ( lastResponse['rid'] != MAX_SENT_PKG_COUNT or currentId != 1): LOG_DEBUG( 'Skipping package processing, received {0}, last processed {1}'. format(currentId, lastResponse['rid'])) return elif _CHAIN_CB_ID is not None: LOG_DEBUG('Already processing package chain, skipping for {0}'.format( currentId)) return else: LOG_DEBUG('Processing package chain, received {0}'.format(currentId)) _execResponse(event.idTypeList) return
def add(self, account, requestID, data, **kw): from Helpers.cache import getFromCache spaceID = data.get('spaceID', '') if spaceID: from adapters.IHangarSpacesAdapter import validateSpaceID from exchangeapi.AdapterUtils import getAdapter if validateSpaceID(spaceID): currentHangarSpaceData = getFromCache( kw['idTypeList'], self._ifacename) or getAdapter( self._ifacename, ['account']).view( None, None, EMPTY_IDTYPELIST) if currentHangarSpaceData is None or currentHangarSpaceData.get( 'spaceID', '') != spaceID: from gui.Scaleform.utils.HangarSpace import g_hangarSpace from BWPersonality import g_lobbyCarouselHelper from db.DBLogic import g_instance as dbInstance hangarSpace = dbInstance.userHangarSpaces[spaceID] g_hangarSpace.refreshSpace(hangarSpace['hangarType'], spaceID) g_lobbyCarouselHelper.queryRefresh3DModel( g_lobbyCarouselHelper.getCarouselAirplaneSelected()) return data return getFromCache(kw['idTypeList'], self._ifacename)
def onSessionBattleResults(event): getAdapter('ISessionBattleResults', ['account']).edit(None, None, EMPTY_IDTYPELIST, event.idTypeList[0][0], reportID=None) return