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);