예제 #1
0
 def enterTestChannel(self):
     verify(not self.inTesting)
     if self.inTesting:
         return
     self.inTesting = True
     self.mainChannel = self.channelsMgr.channel
     self.__enterChannel(self.testChannel, '')
예제 #2
0
    def onCreate(self, name, members, leaderDbID):
        """ Channel has been created by the Game Server.
        
        @param name:       unique channel name from Game Server; used only for further communication with server
        @param members:    list of players with access to this channel (database IDs)
        @param leaderDbID: database ID of channel leader or None if no leader
        """
        LOG_DEBUG('VOIP channel %s (%s) onCreate' % (self.typeName, self.stateName))
        LOG_DEBUG('verify')
        verify(not self.available)
        if self.__mgr.playerID not in members:
            LOG_ERROR('Wrong player ID: %s' % self.__mgr.playerID)
            return
        elif not (leaderDbID is None or leaderDbID in members):
            LOG_ERROR('Wrong leader channel ID: %s' % leaderDbID)
            return
        else:
            self.__name = name
            self.__members.clear()
            for DbID in members:
                self.__members[DbID] = MEMBER_STATES.DISCONNECTED

            self.__leaderDbID = leaderDbID
            self.__onMembersChanged()
            self.processEvent(_FSM_EVENTS.CHANNEL_CREATED)
            return
예제 #3
0
    def initialize(self, tsIdentities, muteList):
        if self.__initialized:
            LOG_ERROR('Already initialized!')
            return
        elif tsIdentities is None or muteList is None:
            return
        else:
            self.__tsIdentities = tsIdentities
            self.__muteList = set(muteList)
            LOG_TRACE('Initialized with TS3 identities: {0}'.format(
                self.__tsIdentities))
            LOG_TRACE('Initialized with mute list: {0}'.format(
                self.__muteList))
            numChannelTypes = len(self.__tsIdentities)
            LOG_DEBUG('verify')
            verify(numChannelTypes == consts.VOIP.CHANNEL_TYPES.QUANTITY)
            args = {ENGINE_PROTOCOL.KEY_PLAYER_DATABASE_ID: str(self.playerID)}
            numSupportedChannels = 0
            for type in xrange(numChannelTypes):
                if self.__tsIdentities[type]:
                    args[
                        ENGINE_PROTOCOL.KEY_CHANNEL_TYPE_INDEXED %
                        numSupportedChannels] = consts.VOIP.CHANNEL_TYPES.getConstNameByValue(
                            type)
                    args[ENGINE_PROTOCOL.KEY_TS_IDENTITY_INDEXED %
                         numSupportedChannels] = self.__tsIdentities[type]
                numSupportedChannels += 1

            args[ENGINE_PROTOCOL.KEY_NUM_CHANNEL_TYPES] = str(
                numSupportedChannels)
            self.__initArgs = args
            if self.__enabled:
                self.__initializeInternal()
            return
예제 #4
0
def LOG_VOIP_INT(msg, *kargs):
    global g_useVivoxlog
    if g_useVivoxlog is None:
        checkUseVivoxLog()
    verify(g_useVivoxlog is not None)
    if g_useVivoxlog:
        _writeLog(msg, kargs)
    elif kargs:
        pass
예제 #5
0
 def initialize(self, domain):
     if not domain:
         return
     if self.vivoxDomain:
         verify(domain == self.vivoxDomain)
         return
     self.vivoxDomain = domain
     self.testChannel = 'sip:confctl-2@' + domain.partition('www.')[2]
     self.channelsMgr.initialize(domain)
예제 #6
0
 def __onLeftChatChannel(self, data):
     if self.channelID == data['channel']:
         if self.inTesting:
             verify(self.mainChannel[0])
             self.mainChannel = ['', '']
         else:
             self.channelID = -1
             verify(not self.mainChannel[0])
             self.__leaveChannel()
예제 #7
0
 def __onLeftChatChannel(self, data):
     if self.channelID == data['channel']:
         if self.inTesting:
             verify(self.mainChannel[0])
             self.mainChannel = ['', '']
         else:
             self.channelID = -1
             verify(not self.mainChannel[0])
             self.__leaveChannel()
예제 #8
0
 def initialize(self, domain):
     if not domain:
         return
     if self.vivoxDomain:
         verify(domain == self.vivoxDomain)
         return
     self.vivoxDomain = domain
     self.testChannel = 'sip:confctl-2@' + domain.partition('www.')[2]
     self.channelsMgr.initialize(domain)
예제 #9
0
 def leaveTestChannel(self):
     verify(self.inTesting)
     if not self.inTesting:
         return
     self.inTesting = False
     if self.mainChannel[0]:
         self.__enterChannel(self.mainChannel[0], self.mainChannel[1])
     else:
         self.__leaveChannel()
     self.mainChannel = ['', '']
예제 #10
0
 def __init__(self, channel, **kwargs):
     super(_StateConnecting, self).__init__(channel)
     LOG_DEBUG('verify')
     verify(channel.hasCredentials)
     LOG_TRACE("VOIP channel %s (%s) trying to connect: key '%s', hash '%s'" % (channel.typeName,
      channel.stateName,
      channel._provisioningKey,
      channel._securityHash))
     VoipEngine.login('', '', {ENGINE_PROTOCOL.KEY_CHANNEL_TYPE: channel.typeName,
      ENGINE_PROTOCOL.KEY_PROVISIONING_KEY: channel._provisioningKey,
      ENGINE_PROTOCOL.KEY_SECURITY_HASH: channel._securityHash})
예제 #11
0
 def _muteParticipantForMe(self, dbid, mute):
     verify(dbid in self.channelUsers)
     self.channelUsers[dbid]['muted'] = mute
     uri = self.channelUsers[dbid]['uri']
     cmd = {}
     cmd[constants.KEY_COMMAND] = constants.CMD_SET_PARTICIPANT_MUTE
     cmd[constants.KEY_PARTICIPANT_URI] = uri
     cmd[constants.KEY_STATE] = str(mute)
     BigWorld.VOIP.command(cmd)
     LOG_DEBUG('mute_for_me: %d, %s' % (dbid, str(mute)))
     self.onParticipantMute(dbid, mute)
     return True
예제 #12
0
 def __onGameNotificationRecieved(self, notificationType, data):
     if len(self.__activeMessages) > notificationType:
         self.__activeMessages[notificationType] -= 1
         verify(not any((count < 0 for count in self.__activeMessages)))
     missionTriggerArgs = self._notificationTypeToMissionTriggerArgs.get(notificationType, None)
     if missionTriggerArgs and not any((self.__activeMessages[notificationId] != 0 for notificationId in self._notificationTypeToMissionTriggerArgs)):
         self.__invalidateMissionStatus(force=missionTriggerArgs.forceMissionUpdate)
         if missionTriggerArgs.callback is not None:
             missionTriggerArgs.callback()
     if notificationType == EPIC_NOTIFICATION.HQ_BATTLE_START:
         self.onObjectiveBattleStarted()
     return
예제 #13
0
 def initialize(self, domain):
     if not domain:
         return
     if self.vivoxDomain:
         verify(domain == self.vivoxDomain)
         return
     LOG_VOIP_INT('VOIPManager.Initialize')
     self.vivoxDomain = domain
     self.testChannel = 'sip:confctl-2@' + domain.partition('www.')[2]
     LOG_VOIP_INT("domain_vivox: '%s'" % self.vivoxDomain)
     LOG_VOIP_INT("domain_test : '%s'" % self.testChannel)
     self.channelsMgr.initialize(domain)
예제 #14
0
 def __muteParticipantForMe(self, dbid, mute):
     verify(dbid in self.channelUsers)
     self.channelUsers[dbid]['muted'] = mute
     uri = self.channelUsers[dbid]['uri']
     cmd = {}
     cmd[constants.KEY_COMMAND] = constants.CMD_SET_PARTICIPANT_MUTE
     cmd[constants.KEY_PARTICIPANT_URI] = uri
     cmd[constants.KEY_STATE] = str(mute)
     BigWorld.VOIP.command(cmd)
     LOG_DEBUG('mute_for_me: %d, %s' % (dbid, str(mute)))
     self.onParticipantMute(dbid, mute)
     return True
예제 #15
0
    def processMessage(self, message, data):
        LOG_TRACE('VOIP channel %s (%s) processMessage: %s' % (self.typeName, self.stateName, ENGINE_PROTOCOL.MESSAGES.getConstNameByValue(message)))
        if message == ENGINE_PROTOCOL.MESSAGES.vmLoggedIn:
            self.processEvent(_FSM_EVENTS.SERVICE_CONNECTED)
            self.__members[self.__mgr.playerID] = MEMBER_STATES.CONNECTED
            self.__onMembersChanged()
            for dbid in self.__mgr.muteList:
                self.applyMemberMuteFlag(dbid, True)

            self.__mgr.refreshVoiceTransmission()
        elif message == ENGINE_PROTOCOL.MESSAGES.vmLoginFailed:
            self.processEvent(_FSM_EVENTS.SERVICE_ERROR, error=int(data[ENGINE_PROTOCOL.KEY_STATUS_CODE]))
        elif message == ENGINE_PROTOCOL.MESSAGES.vmLoggedOut:
            self.processEvent(_FSM_EVENTS.SERVICE_DISCONNECTED, error=int(data[ENGINE_PROTOCOL.KEY_STATUS_CODE]))
            for dbid in self.__members:
                self.__members[dbid] = MEMBER_STATES.DISCONNECTED

            self.__onMembersChanged()
            self.__mgr.refreshVoiceTransmission()
        elif message == ENGINE_PROTOCOL.MESSAGES.vmClientTalkingStatus:
            clientID = int(data[ENGINE_PROTOCOL.KEY_PLAYER_DATABASE_ID])
            talking = data[ENGINE_PROTOCOL.KEY_STATE] == 'True'
            LOG_TRACE('client %d %s' % (clientID, 'TALKING' if talking else 'SILENT'))
            if clientID in self.__members:
                if talking:
                    if self.__members[clientID] != MEMBER_STATES.DISCONNECTED:
                        self.__members[clientID] = MEMBER_STATES.TALKING
                    else:
                        LOG_ERROR('client talking while not connected!')
                elif self.__members[clientID] == MEMBER_STATES.TALKING:
                    self.__members[clientID] = MEMBER_STATES.CONNECTED
                self.__onMembersChanged(clientID)
            elif talking:
                LOG_ERROR('unknown client!')
        elif message == ENGINE_PROTOCOL.MESSAGES.vmClientMoved:
            clientID = int(data[ENGINE_PROTOCOL.KEY_PLAYER_DATABASE_ID])
            LOG_DEBUG('verify')
            verify(clientID != self.__mgr.playerID)
            joined = data[ENGINE_PROTOCOL.KEY_TS_CHANNEL_ID] != '0'
            LOG_TRACE('client %d %s' % (clientID, 'JOINED' if joined else 'LEAVING'))
            if clientID in self.__members:
                if joined:
                    if self.__members[clientID] == MEMBER_STATES.DISCONNECTED:
                        self.__members[clientID] = MEMBER_STATES.CONNECTED
                    muted = clientID in self.__mgr.muteList
                    LOG_TRACE('re-applying mute status (%s) for joined client' % muted)
                    self.applyMemberMuteFlag(clientID, muted)
                else:
                    self.__members[clientID] = MEMBER_STATES.DISCONNECTED
                self.__onMembersChanged(clientID)
            elif joined:
                LOG_ERROR('unknown client joined!')
예제 #16
0
 def __call__(self, message, data={}):
     if message not in [messages.vxParticipantUpdated]:
         msg = '::Message: %d [%s], Data: %s' % (
             message, messages.MESSAGE_IDS[message], data)
         self.debug(msg)
     if message == messages.vxConnectorCreated:
         if data[constants.KEY_CONNECTOR_HANDLE] != '':
             self.initialized = True
             self.onInitialized(data)
             self.__changeState()
     elif message == messages.vxSessionGroupAdded:
         self.loggedIn = True
         self.__changeState()
     elif message == messages.vxSessionGroupRemoved:
         pass
     elif message == messages.vxMediaStreamUpdated:
         state = int(data[constants.KEY_STATE])
         self.debug('CHANNEL DATA: %s' % data)
         if state == constants.SESSION_MEDIA_CONNECTED:
             self.currentChannel = data[constants.KEY_CHANNEL_URI]
             self.onJoinedChannel(data)
             self.__changeState()
         elif state == constants.SESSION_MEDIA_DISCONNECTED:
             self.currentChannel = ''
             self.onLeftChannel(data)
             self.__changeState()
     elif message == messages.vxParticipantRemoved:
         self.onParticipantRemoved(data)
     elif message == messages.vxParticipantAdded:
         self.onParticipantAdded(data)
     elif message == messages.vxParticipantUpdated:
         self.onParticipantUpdated(data)
     elif message == messages.vxAuxGetCaptureDevices:
         self.onCaptureDevicesUpdated(data)
     elif message == messages.vxSessionAdded:
         pass
     elif message == messages.vxSessionRemoved:
         pass
     elif message == messages.vxAccountLogin:
         self.onLogined()
     elif message == messages.vxAccountLogout:
         self.debug('caught vxAccountLogout msg :%s' % data)
         verify(self.currentChannel == '')
         self.loggedIn = False
         self.__changeState()
     elif message == messages.vxAccountLoginStateChange:
         pass
예제 #17
0
 def __call__(self, message, data = {}):
     if message not in [messages.vxParticipantUpdated]:
         msg = '::Message: %d [%s], Data: %s' % (message, messages.MESSAGE_IDS[message], data)
         self.debug(msg)
     if message == messages.vxConnectorCreated:
         if data[constants.KEY_CONNECTOR_HANDLE] != '':
             self.initialized = True
             self.onInitialized(data)
             self.__changeState()
     elif message == messages.vxSessionGroupAdded:
         self.loggedIn = True
         self.__changeState()
     elif message == messages.vxSessionGroupRemoved:
         pass
     elif message == messages.vxMediaStreamUpdated:
         state = int(data[constants.KEY_STATE])
         self.debug('CHANNEL DATA: %s' % data)
         if state == constants.SESSION_MEDIA_CONNECTED:
             self.currentChannel = data[constants.KEY_CHANNEL_URI]
             self.onJoinedChannel(data)
             self.__changeState()
         elif state == constants.SESSION_MEDIA_DISCONNECTED:
             self.currentChannel = ''
             self.onLeftChannel(data)
             self.__changeState()
     elif message == messages.vxParticipantRemoved:
         self.onParticipantRemoved(data)
     elif message == messages.vxParticipantAdded:
         self.onParticipantAdded(data)
     elif message == messages.vxParticipantUpdated:
         self.onParticipantUpdated(data)
     elif message == messages.vxAuxGetCaptureDevices:
         self.onCaptureDevicesUpdated(data)
     elif message == messages.vxSessionAdded:
         pass
     elif message == messages.vxSessionRemoved:
         pass
     elif message == messages.vxAccountLogin:
         self.onLogined()
     elif message == messages.vxAccountLogout:
         self.debug('caught vxAccountLogout msg :%s' % data)
         verify(self.currentChannel == '')
         self.loggedIn = False
         self.__changeState()
     elif message == messages.vxAccountLoginStateChange:
         pass
예제 #18
0
    def onDestroy(self):
        """ Channel has been deleted by the Game Server. """
        LOG_DEBUG('VOIP channel %s onDestroy' % self.typeName)
        LOG_DEBUG('verify')
        verify(self.available)
        if not self.pushToTalkPreserve:
            self.pushToTalkStatus = False
        self.__name = None
        self._failureCount = 0
        self._provisioningKey = None
        self._securityHash = None
        for dbid in self.__members:
            self.__members[dbid] = MEMBER_STATES.DISCONNECTED

        self.__onMembersChanged()
        self.__members.clear()
        self.__leaderDbID = None
        self.__onMembersChanged()
        return
예제 #19
0
    def setMembers(self, dbIDs, leaderDbID):
        LOG_DEBUG('verify')
        verify(self.__mgr.playerID in dbIDs)
        LOG_DEBUG('verify')
        verify(leaderDbID is None or leaderDbID in dbIDs)
        newIDs = set(dbIDs)
        oldIDs = set(self.__members.keys())
        removedIDs = oldIDs - newIDs
        addedIDs = newIDs - oldIDs
        for dbID in removedIDs:
            del self.__members[dbID]

        for dbID in addedIDs:
            self.__members[dbID] = MEMBER_STATES.DISCONNECTED
            VoipEngine.command({ENGINE_PROTOCOL.KEY_COMMAND: ENGINE_PROTOCOL.CMD_REQUEST_CLIENT_STATUS,
             ENGINE_PROTOCOL.KEY_PLAYER_DATABASE_ID: str(dbID)})

        self.__leaderDbID = leaderDbID
        self.__onMembersChanged()
        return
예제 #20
0
 def _onJoinedChannel(self, data):
     self.setVolume()
     verify(not self.channelUsers)
예제 #21
0
 def __onChatResponseMutedError(self, data):
     LOG_ERROR('__onChatResponseMutedError', data.items())
     verify(False and data)
예제 #22
0
 def __onChatResponseMutedError(self, data):
     LOG_ERROR('__onChatResponseMutedError', data.items())
     verify(False and data)
예제 #23
0
 def requestInitData(self, callback):
     verify(callback is not None)
     LOG_TRACE('sending VOIP init data request')
     BigWorld.player().sendOperation(OPERATION_CODE.CMD_VOIP_GET_INIT_DATA,
                                     callback)
     return
예제 #24
0
 def _onJoinedChannel(self, data):
     self.setVolume()
     verify(not self.channelUsers)
예제 #25
0
 def __onChatResponseMutedError(self, data):
     LOG_VOIP_INT('VOIPManager.__onChatResponseMutedError', data.items())
     verify(False and data)
예제 #26
0
 def initialize(self, domain):
     verify(self.domain or not self.initialized)
     verify(self.state == self.STATE_NONE)
     self.domain = domain
     self._changeState()
예제 #27
0
 def initialize(self, domain):
     verify(not (self.domain or self.initialized))
     verify(self.state == self.STATE_NONE)
     self.domain = domain
     self._changeState()