Compress DATA

This commit is contained in:
Maxim Khomutov 2023-07-18 22:40:27 +03:00
parent 69348e9339
commit a226b17612

View File

@ -113,10 +113,6 @@ class Client:
continue
if not to_udp or code in ['V', 'W', 'Y', 'E']:
if code in ['O', 'T'] or len(data) > 1000:
if len(data) > 400:
# TODO: Compress data
await client._send(data)
else:
await client._send(data)
else:
await client._send(data)
@ -125,6 +121,9 @@ class Client:
self.log.debug(f"UDP Part not ready: {code}")
return
if len(data) > 400:
data = b"ABG:" + zlib.compress(data, level=zlib.Z_BEST_COMPRESSION)
header = len(data).to_bytes(4, "little", signed=True)
self.log.debug(f'len: {len(data)}; send: {header + data!r}')
try: