def _sendCapabilities(): for accountDBID, data in xmqp.players_capabilities.iteritems(): #debug('_sendCapabilities: {} {}'.format(accountDBID, data)) if xmqp.XMQP_DEVELOPMENT: if accountDBID == utils.getAccountDBID(): accountDBID = getCurrentAccountDBID() _as_xmqp_event(accountDBID, {'event': EVENTS.XMQP_HOLA, 'capabilities': data})
def _as_xmqp_event(accountDBID, data, targets=TARGETS.ALL): #debug('_as_xmqp_event: {} => {}'.format(accountDBID, data)) if xmqp.XMQP_DEVELOPMENT: if accountDBID == utils.getAccountDBID(): accountDBID = getCurrentAccountDBID() battle = getBattleApp() if not battle: return if not data: warn('[XMQP] no data') return if 'event' not in data: warn('[XMQP] no "event" field in data: %s' % str(data)) return event = data['event'] data = None if not data else unicode_to_ascii(data) if targets & TARGETS.BATTLE: as_xfw_cmd(XVM_BATTLE_COMMAND.AS_XMQP_EVENT, accountDBID, event, data) if targets & TARGETS.VMM: if g_markers.enabled: g_markers.call(XVM_BATTLE_COMMAND.AS_XMQP_EVENT, accountDBID, event, data)
def _as_xmqp_event(accountDBID, data, targets=TARGETS.ALL): #debug('_as_xmqp_event: {} => {}'.format(accountDBID, data)) if xmqp.XMQP_DEVELOPMENT: if accountDBID == utils.getAccountDBID(): accountDBID = getCurrentAccountDBID() battle = getBattleApp() if not battle: return if not data: warn('[XMQP] no data') return if 'event' not in data: warn('[XMQP] no "event" field in data: %s' % str(data)) return event = data['event'] del data['event'] data = None if not data else unicode_to_ascii(data) if targets & TARGETS.BATTLE: as_xfw_cmd(XVM_BATTLE_COMMAND.AS_XMQP_EVENT, accountDBID, event, data) if targets & TARGETS.VMM: if g_markers.active: g_markers.call(XVM_BATTLE_COMMAND.AS_XMQP_EVENT, accountDBID, event, data)
def _sendCapabilities(): for accountDBID, data in list(xmqp.players_capabilities.items()): #debug('_sendCapabilities: {} {}'.format(accountDBID, data)) if xmqp.XMQP_DEVELOPMENT: if accountDBID == utils.getAccountDBID(): accountDBID = getCurrentAccountDBID() _as_xmqp_event(accountDBID, {'event': EVENTS.XMQP_HOLA, 'capabilities': data})
def _start(e=None): g_eventBus.removeListener(XVM_EVENT.XVM_SERVICES_INITIALIZED, _start) if not g_xvm.xvmServicesInitialized: g_eventBus.addListener(XVM_EVENT.XVM_SERVICES_INITIALIZED, _start) return if (config.networkServicesSettings.xmqp and not isReplay()) or XMQP_DEVELOPMENT: token = config.token.token if token: players = [] player = BigWorld.player() for (vehicleID, vData) in player.arena.vehicles.iteritems(): # ally team only if vData['team'] == player.team: players.append(vData['accountDBID']) if XMQP_DEVELOPMENT: accountDBID = utils.getAccountDBID() if accountDBID not in players: players.append(accountDBID) #players.append(42) #players.append(43) # start stop() global _xmqp_thread, _xmqp _xmqp = _XMQP(players) _xmqp_thread = threading.Thread(target=_xmqp.start, name='xmqp') _xmqp_thread.setDaemon(True) _xmqp_thread.start() debug('[XMQP] Thread started')
def _start(e=None): g_eventBus.removeListener(XVM_EVENT.XVM_SERVICES_INITIALIZED, _start) if not g_xvm.xvmServicesInitialized: g_eventBus.addListener(XVM_EVENT.XVM_SERVICES_INITIALIZED, _start) return if config.networkServicesSettings.xmqp or (isReplay() and XMQP_DEVELOPMENT): token = config.token.token if token: players = [] player = BigWorld.player() for (vehicleID, vData) in player.arena.vehicles.iteritems(): # ally team only if vData['team'] == player.team: players.append(vData['accountDBID']) if XMQP_DEVELOPMENT: accountDBID = utils.getAccountDBID() if accountDBID not in players: players.append(accountDBID) #players.append(42) #players.append(43) # start stop() global _xmqp_thread, _xmqp _xmqp = _XMQP(players) _xmqp_thread = threading.Thread(target=_xmqp.start, name='xmqp') _xmqp_thread.setDaemon(True) _xmqp_thread.start() debug('[XMQP] Thread started')
def _onXmqpHola(accountDBID, data): accountDBID = int(accountDBID) if xmqp.XMQP_DEVELOPMENT: if accountDBID == utils.getAccountDBID(): accountDBID = getCurrentAccountDBID() if accountDBID not in xmqp.players_capabilities: xmqp.players_capabilities[accountDBID] = data['capabilities'] #debug('_onXmqpHola: {} {}'.format(accountDBID, data)) _as_xmqp_event(accountDBID, data)
def _stats_down(data): if data['buttonIdx'] == 0: accountDBID = utils.getAccountDBID() try: BigWorld.wg_openWebBrowser(url + str(accountDBID)) except Exception: LOG_ERROR( 'statisticsXVM: there is error while opening web browser') return
def call(self, data): if self.is_consuming: #self._correlation_id = str(uuid.uuid4()) message = simplejson.dumps({'accountDBID': utils.getAccountDBID(), 'data': data}) debug('[XMQP] call: %s' % utils.hide_guid(message)) self._channel.basic_publish( exchange=self._exchange_name, routing_key='', #properties=pika.BasicProperties( # reply_to=self._queue_name, # correlation_id=self._correlation_id), body=message)
def call(self, data): if self.is_consuming and self._exchange_name is not None: try: #self._correlation_id = str(uuid.uuid4()) message = simplejson.dumps({'accountDBID': utils.getAccountDBID(), 'data': data}) debug('[XMQP] call: %s' % utils.hide_guid(message)) self._channel.basic_publish( exchange=self._exchange_name, routing_key='', #properties=pika.BasicProperties( # reply_to=self._queue_name, # correlation_id=self._correlation_id), body=message) except Exception as ex: err('_exchange_name=' + str(self._exchange_name)) err(traceback.format_exc())
def call(self, data): if self.is_consuming and self._exchange_name is not None: try: #self._correlation_id = str(uuid.uuid4()) message = simplejson.dumps( { 'accountDBID': utils.getAccountDBID(), 'data': data }, separators=(',', ':')) debug('[XMQP] call: %s' % utils.hide_guid(message)) self._channel.basic_publish( exchange=self._exchange_name, routing_key='', #properties=pika.BasicProperties( # reply_to=self._queue_name, # correlation_id=self._correlation_id), body=message) except Exception as ex: err('_exchange_name=' + str(self._exchange_name)) err(traceback.format_exc())
def _start(): if config.networkServicesSettings.xmqp or (isReplay() and XMQP_DEVELOPMENT): token = config.token.token if token: players = [] player = BigWorld.player() for (vehicleID, vData) in player.arena.vehicles.iteritems(): # ally team only if vData['team'] == player.team: players.append(vData['accountDBID']) if XMQP_DEVELOPMENT: accountDBID = utils.getAccountDBID() if accountDBID not in players: players.append(accountDBID) #players.append(42) #players.append(43) # start stop() global _xmqp_thread, _xmqp _xmqp = _XMQP(players) _xmqp_thread = threading.Thread(target=_xmqp.start, name='xmqp') _xmqp_thread.setDaemon(True) _xmqp_thread.start() debug('[XMQP] Thread started')