bugfix
This commit is contained in:
parent
c051795d4e
commit
1725184141
@ -47,15 +47,17 @@ class UdpWidget(EventDispatcher):
|
|||||||
self.get_peer_pubkey()
|
self.get_peer_pubkey()
|
||||||
|
|
||||||
def get_peer_pubkey(self, peer_id=None, timeout=1):
|
def get_peer_pubkey(self, peer_id=None, timeout=1):
|
||||||
|
print('get_peer_pubkey(), called..')
|
||||||
d = {
|
d = {
|
||||||
'c':'get_pubkey',
|
'c':'get_pubkey',
|
||||||
'd':{
|
'd':{
|
||||||
'pubkey':self.dataencoder.my_text_publickey()
|
'pubkey':self.dataencoder.my_text_publickey()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b = json.dumps(d).encode('utf-8')
|
b = b'0x00' * 18 + json.dumps(d).encode('utf-8')
|
||||||
self.udp_transport.broadcast(b)
|
self.udp_transport.broadcast(b)
|
||||||
if peer_id is None:
|
if peer_id is None:
|
||||||
|
print('get_peer_pubkey():return')
|
||||||
return
|
return
|
||||||
t = t1 = time.time()
|
t = t1 = time.time()
|
||||||
t1 += timeout
|
t1 += timeout
|
||||||
@ -67,7 +69,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)
|
print('comm_callback():', 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:]
|
||||||
@ -80,16 +82,20 @@ class UdpWidget(EventDispatcher):
|
|||||||
else:
|
else:
|
||||||
d = self.dataencoder.unpack(addr[0], data)
|
d = self.dataencoder.unpack(addr[0], data)
|
||||||
if d is None:
|
if d is None:
|
||||||
|
print('comm_callback(): d is None')
|
||||||
return
|
return
|
||||||
if not isinstance(d, dict):
|
if not isinstance(d, dict):
|
||||||
|
print('comm_callback(): d is not a dict data')
|
||||||
return
|
return
|
||||||
print('received: data=', d)
|
print('received: data=', d)
|
||||||
cmd = d['c']
|
cmd = d['c']
|
||||||
f = self.inner_handler(cmd)
|
f = self.inner_handler(cmd)
|
||||||
if f:
|
if f:
|
||||||
f(d, addr)
|
f(d, addr)
|
||||||
|
print('comm_callback():inner callback called(),', cmd)
|
||||||
return
|
return
|
||||||
if cmd in self.block_commands:
|
if cmd in self.block_commands:
|
||||||
|
print('comm_callback():', cmd, 'is blocked')
|
||||||
return
|
return
|
||||||
evt_name = 'on_%s' % cmd
|
evt_name = 'on_%s' % cmd
|
||||||
evt_data = {
|
evt_data = {
|
||||||
|
Loading…
Reference in New Issue
Block a user