add
This commit is contained in:
parent
013c6124d9
commit
551c1437e5
@ -48,8 +48,8 @@ Usage:
|
||||
-tcp_rst tcp的超时发送时间,默认400ms
|
||||
Tcp timeout resend time, default 400ms
|
||||
|
||||
-tcp_gz tcp数据开启压缩,默认0
|
||||
Whether the tcp data is compressed or not, the default is 0.
|
||||
-tcp_gz 当数据包超过这个大小,tcp将压缩数据,0表示不压缩,默认0
|
||||
Tcp will compress data when the packet exceeds this size, 0 means no compression, default 0
|
||||
`
|
||||
|
||||
func main() {
|
||||
|
@ -98,7 +98,7 @@ func (fm *FrameMgr) cutSendBufferToWindow() {
|
||||
Data: make([]byte, FRAME_MAX_SIZE)}
|
||||
fm.sendb.Read(fd.Data)
|
||||
|
||||
if fm.compress > 0 {
|
||||
if fm.compress > 0 && len(fd.Data) > fm.compress {
|
||||
newb := fm.compressData(fd.Data)
|
||||
if len(newb) < len(fd.Data) {
|
||||
fd.Data = newb
|
||||
@ -124,7 +124,7 @@ func (fm *FrameMgr) cutSendBufferToWindow() {
|
||||
Data: make([]byte, fm.sendb.Size())}
|
||||
fm.sendb.Read(fd.Data)
|
||||
|
||||
if fm.compress > 0 {
|
||||
if fm.compress > 0 && len(fd.Data) > fm.compress {
|
||||
newb := fm.compressData(fd.Data)
|
||||
if len(newb) < len(fd.Data) {
|
||||
fd.Data = newb
|
||||
@ -218,7 +218,7 @@ func (fm *FrameMgr) preProcessRecvList() (map[int32]int, map[int32]int, map[int3
|
||||
} else if f.Type == (int32)(Frame_PONG) {
|
||||
fm.processPong(f)
|
||||
} else {
|
||||
loggo.Error("error frame type %s", f.Type)
|
||||
loggo.Error("error frame type %d", f.Type)
|
||||
}
|
||||
}
|
||||
fm.recvlist.Init()
|
||||
@ -552,6 +552,7 @@ func (fm *FrameMgr) compressData(src []byte) []byte {
|
||||
var b bytes.Buffer
|
||||
w := zlib.NewWriter(&b)
|
||||
w.Write(src)
|
||||
w.Close()
|
||||
return b.Bytes()
|
||||
}
|
||||
|
||||
|
@ -95,4 +95,10 @@ func Test0001(t *testing.T) {
|
||||
fm.recvid = 13
|
||||
fm.windowsize = 10000
|
||||
fmt.Println("fm.isIdOld = ", fm.isIdOld(9, FRAME_MAX_ID))
|
||||
|
||||
dd := fm.compressData(([]byte)("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
|
||||
fmt.Println("fm.compressData = ", len(dd))
|
||||
|
||||
_, ddd := fm.deCompressData(dd)
|
||||
fmt.Println("fm.deCompressData = ", (string)(ddd))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user