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 #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 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 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)
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 sendToggleAFK(self, afk): if afk: val = 1 else: val = 0 self.sendAndRemember(Protocol.TOGGLE_AFK, Protocol.packInt(val))