This commit is contained in:
yumoqing 2021-07-14 14:41:22 +08:00
parent 4dac61a5f8
commit 88a8888859

View File

@ -67,6 +67,7 @@ class UdpWidget(EventDispatcher):
raise Exception('timeout') raise Exception('timeout')
def comm_callback(self, data, addr): def comm_callback(self, data, addr):
print('received:', data, 'addr=', addr)
d = None d = None
if data[:18] == b'0x00' * 18: if data[:18] == b'0x00' * 18:
data = data[18:] data = data[18:]
@ -82,6 +83,7 @@ class UdpWidget(EventDispatcher):
return return
if not isinstance(d, dict): if not isinstance(d, dict):
return return
print('received: data=', d)
cmd = d['c'] cmd = d['c']
f = self.inner_handler(cmd) f = self.inner_handler(cmd)
if f: if f:
@ -121,6 +123,7 @@ class UdpWidget(EventDispatcher):
def send(self, peer_id, data): def send(self, peer_id, data):
d = self.dataencoder.pack(peer_id, data) d = self.dataencoder.pack(peer_id, data)
addr = (peer_id, self.udp_port) addr = (peer_id, self.udp_port)
print('send():', peer_id, data)
self.udp_transport.send(d, addr) self.udp_transport.send(d, addr)
def stop(self): def stop(self):