From a226b1761226a744fa0e776bd05d75b69bf6348d Mon Sep 17 00:00:00 2001 From: SantaSpeen Date: Tue, 18 Jul 2023 22:40:27 +0300 Subject: [PATCH] Compress DATA --- src/core/Client.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core/Client.py b/src/core/Client.py index f39bb04..05a2db1 100644 --- a/src/core/Client.py +++ b/src/core/Client.py @@ -113,11 +113,7 @@ 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) + await client._send(data) else: await client._send(data) else: @@ -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: