From 4b57324ca2c36d22c6ad91b95a90e574cefb75cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=BB=E9=AD=82=E5=9C=A3=E4=BD=BF?= Date: Mon, 3 Jun 2024 13:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E8=AE=BE=E5=AE=9A=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=8E=8B=E7=BC=A9=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Transmit.cpp | 5 +++-- src/Transmit.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Transmit.cpp b/src/Transmit.cpp index 393aa82..7dca784 100644 --- a/src/Transmit.cpp +++ b/src/Transmit.cpp @@ -13,6 +13,7 @@ namespace Transmission { const int32_t Transmit::DATA_STOP = 0x20030507; + int Transmit::compressSize = 64; Transmit::Transmit(SOCKET fd, std::string ip) : ip(std::move(ip)), fd(fd) { @@ -123,8 +124,8 @@ namespace Transmission { dataPackets.set_type(type); std::string byteData(reinterpret_cast(data), size); dataPackets.set_data(byteData); - if (size < 64) { - //小于64字节的数据包不压缩 + if (size < compressSize) { + //小于compressSize的数据包不压缩 pushData(dataPackets); } else { //大于64字节的数据使用lzma压缩后发送 diff --git a/src/Transmit.h b/src/Transmit.h index 37acf01..cd5fa52 100644 --- a/src/Transmit.h +++ b/src/Transmit.h @@ -58,6 +58,8 @@ namespace Transmission { virtual std::shared_ptr unLzma(const std::string &str, size_t &size); public: + //最小压缩大小 + static int compressSize; static const int32_t DATA_STOP; explicit Transmit(SOCKET fd, std::string ip);