Skip to content

Commit c79f025

Browse files
committed
adjust zwlib example
1 parent 4445df2 commit c79f025

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

12.network/zhiwu.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def __init__(self, crypt = 43, entid = 1, devid = "0123456789ABC", devip = 1):
1717
def __del__(self):
1818
encode_del(self.en)
1919

20+
def get(self):
21+
return encode_parse(self.en)
22+
2023
def __str__(self):
2124
return encode_parse(self.en)
2225

@@ -34,6 +37,9 @@ def __init__(self, crypt = 3):
3437
def __del__(self):
3538
decode_del(self.de)
3639

40+
def get(self):
41+
return decode_parse(self.de)
42+
3743
def __str__(self):
3844
return decode_parse(self.de)
3945

12.network/zw_tran.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
A = zhiwu.encode(43)
77
B = zhiwu.decode(55)
88

9-
ServerIP = '192.168.123.97'
10-
# ServerIP = '10.10.10.215'
9+
# ServerIP = '192.168.123.97'
10+
ServerIP = '10.10.10.215'
1111

1212
xAsyncSocketsPool = XAsyncSockets.XAsyncSocketsPool()
1313
xAsyncUDPDatagram = XAsyncSockets.XAsyncUDPDatagram.Create(xAsyncSocketsPool, ('0.0.0.0', 32))
1414

1515
def _onUDPDatagramDataRecv(xAsyncUDPDatagram, remoteAddr, datagram) :
16-
print('On UDP Datagram Data Recv (%s:%s) :' % remoteAddr, bytes(datagram))
16+
# print('On UDP Datagram Data Recv (%s:%s) :' % remoteAddr, bytes(datagram))
1717
# print(str(B.core(bytes(datagram))))
1818
print(B.parse(bytes(datagram)))
1919
print(B)
2020

2121

2222
def _onUDPDatagramFailsToSend(xAsyncUDPDatagram, datagram, remoteAddr) :
23-
print('On UDP Datagram Fails To Send', datagram, remoteAddr)
23+
print('On UDP Datagram Fails To Send', bytes(datagram), remoteAddr)
2424

2525
if xAsyncUDPDatagram:
2626
xAsyncUDPDatagram.OnFailsToSend = _onUDPDatagramFailsToSend
@@ -42,7 +42,7 @@ def tran_server():
4242
import time
4343
while True:
4444
time.sleep(1)
45-
Pack = A.collect("source", str(time.time()))
45+
Pack = A.collect("sync", str(time.time()))
4646
xAsyncUDPDatagram.AsyncSendDatagram(datagram=bytearray(Pack), remoteAddr=(ServerIP, 9954))
4747
print(A)
4848

0 commit comments

Comments
 (0)