def dataReceived(self, data): msg=Message() datapack=DataPack(msg) msglen,msgid,msgdata=datapack.unpack(data) print('[Server] receive data %r from num %r , len:%r , id:%r' % (msgdata, self.peer,msglen,msgid)) #根据包的ID进行router分发处理 routerID=self.routers.apis.get(msgid,None) if routerID: #发送数据 routerID(self.peer,self.transport) else: self.sendData(b'ping....ping....', 1)
def dataReceived(self, data): msg = Message() datapack = DataPack(msg) msglen, msgid, msgdata = datapack.unpack(data) print('[Client] receive data %r from server, len:%r , id:%r' % (msgdata,msglen, msgid))