允许设定最小压缩大小
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
namespace Transmission {
|
namespace Transmission {
|
||||||
|
|
||||||
const int32_t Transmit::DATA_STOP = 0x20030507;
|
const int32_t Transmit::DATA_STOP = 0x20030507;
|
||||||
|
int Transmit::compressSize = 64;
|
||||||
|
|
||||||
Transmit::Transmit(SOCKET fd, std::string ip) : ip(std::move(ip)), fd(fd) {
|
Transmit::Transmit(SOCKET fd, std::string ip) : ip(std::move(ip)), fd(fd) {
|
||||||
|
|
||||||
@@ -123,8 +124,8 @@ namespace Transmission {
|
|||||||
dataPackets.set_type(type);
|
dataPackets.set_type(type);
|
||||||
std::string byteData(reinterpret_cast<const char *>(data), size);
|
std::string byteData(reinterpret_cast<const char *>(data), size);
|
||||||
dataPackets.set_data(byteData);
|
dataPackets.set_data(byteData);
|
||||||
if (size < 64) {
|
if (size < compressSize) {
|
||||||
//小于64字节的数据包不压缩
|
//小于compressSize的数据包不压缩
|
||||||
pushData(dataPackets);
|
pushData(dataPackets);
|
||||||
} else {
|
} else {
|
||||||
//大于64字节的数据使用lzma压缩后发送
|
//大于64字节的数据使用lzma压缩后发送
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ namespace Transmission {
|
|||||||
virtual std::shared_ptr<unsigned char> unLzma(const std::string &str, size_t &size);
|
virtual std::shared_ptr<unsigned char> unLzma(const std::string &str, size_t &size);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//最小压缩大小
|
||||||
|
static int compressSize;
|
||||||
static const int32_t DATA_STOP;
|
static const int32_t DATA_STOP;
|
||||||
|
|
||||||
explicit Transmit(SOCKET fd, std::string ip);
|
explicit Transmit(SOCKET fd, std::string ip);
|
||||||
|
|||||||
Reference in New Issue
Block a user