def route_message(self, di, datagram, reciever_channel, sender_channel): dg = PyDatagram() dg.addUint64(reciever_channel) dg.addUint64(sender_channel) dg.addUint16(di.getUint16()) dg.appendData(di.getRemainingBytes()) self.cw.send(dg, self.interface.registeredParticipants[reciever_channel]) dg.clear()
def sendDisconnectClient(self, di, connection, errorCode, reason): datagram = PyDatagram() datagram.addUint16(CLIENT_GO_GET_LOST) datagram.addUint16(errorCode) datagram.addString(reason) self.cw.send(datagram, connection) datagram.clear() self.handleClientDisconnected(di, connection)
def enterSetAccount(self): datagram = PyDatagram() datagram.addServerHeader(self.connectionId, self.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL) datagram.addUint64( self.accMgr.GetAccountConnectionChannel(self.accountId)) # TODO! self.air.send(datagram) datagram.clear() # Cleanse data datagram = PyDatagram() datagram.addServerHeader(self.connectionId, self.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID) datagram.addUint64(self.accountId << 32) self.air.send(datagram) datagram.clear() # Cleanse data datagram = PyDatagram() datagram.addServerHeader(self.connectionId, self.air.ourChannel, CLIENTAGENT_SET_STATE) datagram.addUint16(2) # ESTABLISHED self.air.send(datagram) datagram.clear() # Cleanse data fields = { 'ACCOUNT_LAST_LOGIN': strftime("%Y-%m-%d %H:%M:%S", gmtime()) } self.air.dbInterface.updateObject( databaseId=self.accMgr.dbId, doId=self.accountId, dclass=self.air.dclassesByName['AccountManagerUD'], newFields=fields) # We're done here send a response. self.accMgr.sendUpdateToChannel(self.connectionId, 'recieveAvatar', [self.potAvList]) self.demand("Off")
def unregisterChannel(self, channel): datagram = PyDatagram() datagram.addUint16(CONTROL_REMOVE_CHANNEL) datagram.addUint64(channel) self.cw.send(datagram, self.connection) datagram.clear()