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)
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)
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)
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
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.sigStatusMessage.emit("Challenging "+name) self.sendAndRemember(Protocol.SEND_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom)) self.challenged = name
def sendCancelChallenge(self, name=None): if (name is None and self.challenged) or (name and name == self.challenged): self.sigStatusMessage.emit("Cancelling challenge") self.sendAndRemember(Protocol.CANCEL_CHALLENGE, Protocol.packTLV(self.challenged)) self.challenged = None
def sendAuth(self, username, password): self.username = username try: port = self.udpSock.getsockname()[1] except: port=6009 #raise # piggyback the OS and timezone onto the login request since there doesn't seem to be another convenient place to send it. authdata = Protocol.packTLV(username) + Protocol.packTLV(password) + Protocol.packInt(port) + \ Protocol.packInt(copyright.versionNum()) + \ Protocol.packInt(self.os) + \ Protocol.packTLV(str(self.utcoffset)) # There's a string conversion error here if packInt returns any #Protocol.packInt(self.utcoffset) # non-ascii bytes. Send utcoffset as a string for now. self.sendAndRemember(Protocol.AUTH, authdata)
def sendJoinChannelRequest(self, channel=None): if channel: self.channel = channel Settings.setValue(Settings.SELECTED_CHANNEL, channel) if channel in self.channels: if channel != 'lobby': self.rom = self.channels[channel]['rom'] else: self.rom = '' else: logdebug().error("Invalid channel {}".format(channel)) if (int(self.channelport) != int(self.channels[channel]['port'])): self.switchingServer = True self.channelport = int(self.channels[channel]['port']) Settings.setValue(Settings.PORT, self.channelport) self.tcpSock.close() self.sequence = 0x1 self.connectTcp() self.sendWelcome() self.sendAuth(self.username, self.password) if Settings.value(Settings.AWAY): self.sendToggleAFK(1) self.sendAndRemember(Protocol.JOIN_CHANNEL, Protocol.packTLV(self.channel))
def sendJoinChannelRequest(self, channel=None): if channel: self.channel = channel Settings.setValue(Settings.SELECTED_CHANNEL, channel) if channel in self.channels: if channel != 'lobby': self.rom = self.channels[channel]['rom'] else: logdebug().error("Invalid channel {}".format(channel)) self.sendAndRemember(Protocol.JOIN_CHANNEL, Protocol.packTLV(self.channel))
def sendMessage(self, extID, prefix, params=None): """ Encode a message and send it to the server Args: extID: positive integer. 0 for internal messages, 1 for referee messages, otherwise is an extension ID prefix: extension-defined positive integer params: json-serializable python object """ data = Protocol.packInt(extID) + Protocol.packInt(prefix) + json.dumps( params) self.controller.sendAndRemember(Protocol.EXTENSION_OUTBOUND, Protocol.packTLV(data)) # DEBUG dispext = "Extension" if extID == 0 else _ExtensionDict[extID].__name__ dispprefix = self._codeToString.get((extID, prefix), prefix) self.controller.sigStatusMessage.emit( "Ext Snd: ext=%s, prefix=%s, params=%s" % (dispext, dispprefix, params))
def sendJoinChannelRequest(self, channel=None): if channel: self.channel = channel Settings.setValue(Settings.SELECTED_CHANNEL, channel) if channel in self.channels: if channel != 'lobby': self.rom = self.channels[channel]['rom'] else: self.rom = '' else: logdebug().error("Invalid channel {}".format(channel)) if (int(self.channelport)!=int(self.channels[channel]['port'])): self.switchingServer=True self.channelport = int(self.channels[channel]['port']) Settings.setValue(Settings.PORT, self.channelport) self.tcpSock.close() self.sequence = 0x1 self.connectTcp() self.sendWelcome() self.sendAuth(self.username, self.password) if Settings.value(Settings.AWAY): self.sendToggleAFK(1) self.sendAndRemember(Protocol.JOIN_CHANNEL, Protocol.packTLV(self.channel))
def sendDeclineChallenge(self, name): self.sendAndRemember(Protocol.DECLINE_CHALLENGE, Protocol.packTLV(name)) if name in self.challengers: self.challengers.remove(name)
def sendChat(self, line): if self.channel == 'unsupported' and self.unsupportedRom: line = '[' + self.unsupportedRom + '] ' + line line = line.encode('utf-8') self.sendAndRemember(Protocol.CHAT, Protocol.packTLV(line))
def sendAcceptChallenge(self, name): if name in self.challengers: self.sendAndRemember( Protocol.ACCEPT_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom)) self.challengers.remove(name)
def sendCancelChallenge(self, name=None): if (name is None and self.challenged) or (name and name == self.challenged): self.sendAndRemember(Protocol.CANCEL_CHALLENGE, Protocol.packTLV(self.challenged)) self.challenged = None
def sendAuth(self, username, password): self.username = username authdata = Protocol.packTLV(username) + Protocol.packTLV( password) + "\x00\x00\x17\x79" self.sendAndRemember(Protocol.AUTH, authdata)
def sendAuth(self, username, password): self.username = username authdata = Protocol.packTLV(username) + Protocol.packTLV(password) + "\x00\x00\x17\x79" self.sendAndRemember(Protocol.AUTH, authdata)
def sendChallenge(self, name): self.sendCancelChallenge() self.sendAndRemember(Protocol.SEND_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom)) self.challenged = name
def sendChallenge(self, name): self.sendCancelChallenge() self.sendAndRemember( Protocol.SEND_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom)) self.challenged = name
def sendAcceptChallenge(self, name): if name in self.challengers: self.sendAndRemember(Protocol.ACCEPT_CHALLENGE, Protocol.packTLV(name) + Protocol.packTLV(self.rom)) self.challengers.remove(name)
def sendSpectateRequest(self, name): isFbaPresent = self.checkInstallation() isRomPresent = self.checkRom() if not isRomPresent or not isFbaPresent: return self.sendAndRemember(Protocol.SPECTATE, Protocol.packTLV(name))
def sendSpectateRequest(self, name): self.sendAndRemember(Protocol.SPECTATE, Protocol.packTLV(name))