当前位置: 首页>>代码示例>>Python>>正文


Python protocol.Protocol类代码示例

本文整理汇总了Python中ggpo.common.protocol.Protocol的典型用法代码示例。如果您正苦于以下问题:Python Protocol类的具体用法?Python Protocol怎么用?Python Protocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Protocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parseChallengeReceivedResponse

 def parseChallengeReceivedResponse(self, data):
     name, data = Protocol.extractTLV(data)
     rom, data = Protocol.extractTLV(data)
     if rom != self.rom or name in self.ignored:
         return
     self.challengers.add(name)
     self.sigChallengeReceived.emit(name)
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:7,代码来源:controller.py

示例2: dispatchInbandData

    def dispatchInbandData(self, seq, data):
        if not seq in self.tcpCommandsWaitingForResponse:
            logdebug().error("Sequence {} data {} not matched".format(seq, data))
            return

        origRequest = self.tcpCommandsWaitingForResponse[seq]
        del self.tcpCommandsWaitingForResponse[seq]

        if origRequest == Protocol.AUTH:
            self.parseAuthResponse(data)
        elif origRequest == Protocol.MOTD:
            self.parseMotdResponse(data)
        elif origRequest == Protocol.LIST_CHANNELS:
            self.parseListChannelsResponse(data)
        elif origRequest == Protocol.LIST_USERS:
            self.parseListUsersResponse(data)
        elif origRequest == Protocol.SPECTATE:
            status, data = Protocol.extractInt(data)
            if status != 0:
                self.sigStatusMessage.emit("Fail to spectate " + str(status))
        elif origRequest in [Protocol.WELCOME, Protocol.JOIN_CHANNEL, Protocol.TOGGLE_AFK,
                             Protocol.SEND_CHALLENGE, Protocol.CHAT, Protocol.ACCEPT_CHALLENGE,
                             Protocol.DECLINE_CHALLENGE, Protocol.CANCEL_CHALLENGE]:
            if len(data) == 4:
                status, data = Protocol.extractInt(data)
                if status != 0:
                    codestr = Protocol.codeToString(origRequest)
                    logdebug().error("{} failed, data {}".format(codestr, repr(data)))
                    self.sigActionFailed.emit(codestr)
            else:
                logdebug().error("Unknown response for {}; seq {}; data {}".format(
                    Protocol.codeToString(origRequest), seq, repr(data)))
        else:
            logdebug().error("Not handling {} response; seq {}; data {}".format(
                Protocol.codeToString(origRequest), seq, repr(data)))
开发者ID:marcelosjrp,项目名称:pyqtggpo,代码行数:35,代码来源:controller.py

示例3: parseMotdResponse

 def parseMotdResponse(self, data):
     if not data:
         return
     status, data = Protocol.extractInt(data)
     channel, data = Protocol.extractTLV(data)
     topic, data = Protocol.extractTLV(data)
     msg, data = Protocol.extractTLV(data)
     self.sigMotdReceived.emit(channel, topic, msg)
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:8,代码来源:controller.py

示例4: sendAcceptChallenge

 def sendAcceptChallenge(self, name):
     isFbaPresent = self.checkInstallation()
     isRomPresent = self.checkRom()
     if not isRomPresent or not isFbaPresent:
         return
     if name in self.challengers:
         self.sendAndRemember(Protocol.ACCEPT_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom))
         self.challengers.remove(name)
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:8,代码来源:controller.py

示例5: sendAuth

 def sendAuth(self, username, password):
     self.username = username
     try:
         port = self.udpSock.getsockname()[1]
     except:
         port=6009
     authdata = Protocol.packTLV(username) + Protocol.packTLV(password) + Protocol.packInt(port) + Protocol.packInt(copyright.versionNum())
     self.sendAndRemember(Protocol.AUTH, authdata)
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:8,代码来源:controller.py

示例6: parseChatResponse

 def parseChatResponse(self, data):
     name, data = Protocol.extractTLV(data)
     if name in self.ignored:
         return
     msg, data = Protocol.extractTLV(data)
     try:
         msg = msg.decode('utf-8')
     except ValueError:
         msg = msg
     self.sigChatReceived.emit(name, msg)
开发者ID:0nepice,项目名称:pyqtggpo,代码行数:10,代码来源:controller.py

示例7: sendChallenge

 def sendChallenge(self, name):
     self.sendCancelChallenge()
     isFbaPresent = self.checkInstallation()
     isRomPresent = self.checkRom()
     if not isRomPresent or not isFbaPresent:
         return
     if (name==self.username):
         self.runFBA(self.channel)
     else:
         self.sendAndRemember(Protocol.SEND_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom))
         self.challenged = name
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:11,代码来源:controller.py

示例8: parseChatResponse

 def parseChatResponse(self, data):
     name, data = Protocol.extractTLV(data)
     if name in self.ignored:
         return
     msg, data = Protocol.extractTLV(data)
     try:
         msg = msg.decode('utf-8')
     except ValueError:
         msg = msg
     if Settings.USER_LOG_CHAT:
         loguser().info(u"<{}> {}".format(name, msg))
     self.sigChatReceived.emit(name, msg)
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:12,代码来源:controller.py

示例9: parseListChannelsResponse

 def parseListChannelsResponse(self, data):
     #self.channels = {}
     if len(data) <= 8:
         logdebug().error('No channels found')
         self.sigChannelsLoaded.emit()
         return
     status1, data = Protocol.extractInt(data)
     status2, data = Protocol.extractInt(data)
     logdebug().info("Load channels header " + repr(status1) + repr(status2))
     while len(data) > 4:
         room, data = Protocol.extractTLV(data)
         romname, data = Protocol.extractTLV(data)
         title, data = Protocol.extractTLV(data)
         users, data = Protocol.extractInt(data)
         port, data = Protocol.extractInt(data)
         index, data = Protocol.extractInt(data)
         # 'sfa3': {'title': 'Street Fighter Alpha 3', 'rom': 'sfa3:sfa3u', 'room': 'sfa3'},
         # 'sfa2': {'title': 'Street Fighter Alpha 2', 'rom': 'sfa2', 'room': 'sfa2'},
         channel = {
             'rom': romname.split(':')[0],
             'room': room,
             'title': title,
             'users': users,
             'port': port,
         }
         self.channels[room] = channel
     logdebug().info(repr(self.channels))
     self.sigChannelsLoaded.emit()
     if len(data) > 0:
         logdebug().error('Channel REMAINING DATA len {} {}'.format(len(data), repr(data)))
开发者ID:TrueFocus,项目名称:pyqtggpo,代码行数:30,代码来源:controller.py

示例10: parseChallengeDeclinedResponse

 def parseChallengeDeclinedResponse(self, data):
     name, data = Protocol.extractTLV(data)
     if name == self.challenged:
         self.challenged = None
     if name in self.ignored:
         return
     self.sigChallengeDeclined.emit(name)
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:7,代码来源:controller.py

示例11: parseChallengeCancelledResponse

 def parseChallengeCancelledResponse(self, data):
     name, data = Protocol.extractTLV(data)
     if name in list(self.challengers):
         self.challengers.remove(name)
     if name in self.ignored:
         return
     self.sigChallengeCancelled.emit(name)
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:7,代码来源:controller.py

示例12: parseSpectateResponse

 def parseSpectateResponse(self, data):
     p1, data = Protocol.extractTLV(data)
     p2, data = Protocol.extractTLV(data)
     # if the guy I challenged accepted, remove him as challenged
     if self.challenged and self.challenged in [p1, p2] and self.username in [p1, p2]:
         self.challenged = None
         # quark len(53) = 'quark:stream,ssf2t,challenge-07389-1393539605.46,7000'
     quark, data = Protocol.extractTLV(data)
     logdebug().info("Quark " + repr(quark))
     if quark.startswith('quark:served'):
         smooth = Settings.value(Settings.SMOOTHING)
         if smooth:
             match = re.search(r'[0-9]+', smooth)
             if match:
                 quark += ',{}'.format(match.group(0))
     self.runFBA(quark)
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:16,代码来源:controller.py

示例13: parseStateChangesResponse

    def parseStateChangesResponse(self, data):
        count, data = Protocol.extractInt(data)
        while count > 0 and len(data) >= 4:
            state, p1, p2, playerinfo, data = self.__class__.extractStateChangesResponse(data)
            if state == PlayerStates.PLAYING:
                self.parsePlayerStartGameResponse(p1, p2, playerinfo)
		if self.username == p1:
			self.playingagainst = p2
		if self.username == p2:
			self.playingagainst = p1
                if Settings.USER_LOG_PLAYHISTORY and self.username in [p1, p2]:
                    loguser().info(u"[IN A GAME] {} vs {}".format(p1, p2))
            elif state == PlayerStates.AVAILABLE:
                self.parsePlayerAvailableResponse(p1, playerinfo)
                if self.playingagainst == p1:
                    self.playingagainst = ''
                    self.killEmulator()
            elif state == PlayerStates.AFK:
                self.parsePlayerAFKResponse(p1, playerinfo)
                if self.playingagainst == p1:
                    self.playingagainst = ''
                    self.killEmulator()
            elif state == PlayerStates.QUIT:
                self.parsePlayerLeftResponse(p1)
            else:
                logdebug().error(
                    "Unknown state change payload state: {} {}".format(state, repr(data)))
            if state == PlayerStates.PLAYING:
                msg = p1 + ' ' + PlayerStates.codeToString(state) + ' ' + p2
            else:
                msg = p1 + ' ' + PlayerStates.codeToString(state)
            logdebug().info(msg)
            count -= 1
        if len(data) > 0:
            logdebug().error("stateChangesResponse, remaining data {}".format(repr(data)))
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:35,代码来源:controller.py

示例14: parseAuthResponse

 def parseAuthResponse(self, data):
     if len(data) < 4:
         logdebug().error("Unknown auth response {}".format(repr(data)))
         return
     result, data = Protocol.extractInt(data)
     if result == 0:
         self.selectTimeout = 15
         self.sigLoginSuccess.emit()
     # password incorrect, user incorrect
     #if result == 0x6 or result == 0x4:
     else:
         if self.tcpSock:
             self.tcpSock.close()
             self.tcpConnected = False
         #if self.udpSock:
         #    self.udpSock.close()
         #    self.udpConnected = False
         self.sigLoginFailed.emit()
         #self.sigStatusMessage.emit("Login failed {}".format(result))
         if result==6:
             self.sigStatusMessage.emit("Login failed: wrong password")
         elif result==9:
             self.sigStatusMessage.emit("Login failed: too many connections")
         elif result==4:
             self.sigStatusMessage.emit("Login failed: username doesn't exist into database")
         elif result==8:
             self.sigStatusMessage.emit("Clone connection closed.\nPlease login again.")
         else:
             self.sigStatusMessage.emit("Login failed {}".format(result))
开发者ID:TrueFocus,项目名称:pyqtggpo,代码行数:29,代码来源:controller.py

示例15: sendToggleAFK

 def sendToggleAFK(self, afk):
     if afk:
         val = 1
         state = True
     else:
         val = 0
         state = False
     self.sendAndRemember(Protocol.TOGGLE_AFK, Protocol.packInt(val))
     Settings.setBoolean(Settings.AWAY, state)
开发者ID:pond3r,项目名称:pyqtggpo,代码行数:9,代码来源:controller.py


注:本文中的ggpo.common.protocol.Protocol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。