/// <summary> /// 自动压缩 /// </summary> /// <param name="buffer"></param> /// <returns>返回压缩后的字节</returns> public byte[] CompressBuffer(byte[] buffer) { if (buffer.Length > EnableGzipMinByte) { return(GzipUtils.EnCompress(buffer, 0, buffer.Length)); } return(buffer); }
/// <summary> /// 写入Gzip压缩的Buffer,返回压缩后的长度 /// </summary> /// <returns></returns> private int WriteGzipCompressBuffer(byte[] orgData) { byte[] buffer = GzipUtils.EnCompress(orgData, 0, orgData.Length); int gzipLength = buffer.Length; WriteByte(gzipLength);//分包时通过此长度计算来组包 WriteByte(buffer); return(gzipLength); }
private static byte[] CompressGzipBuffer(byte[] data) { return(GzipUtils.EnCompress(data, 0, data.Length)); }