This commit is contained in:
黄思敏 2022-08-30 11:44:08 +08:00
parent 288bc1e699
commit 3125dbb804

View File

@ -16,6 +16,7 @@ import (
"sync/atomic"
"time"
"github.com/klauspost/compress/zstd"
"github.com/songgao/packets/ethernet"
"github.com/songgao/water"
"github.com/songgao/water/waterutil"
@ -97,14 +98,14 @@ func (cli *RPCClient) run() {
}
// zstd compress
// zenc, err := zstd.NewWriter(buf)
// if err != nil {
// log.Panic(err)
// }
// err = zenc.Flush()
// if err != nil {
// log.Println(err)
// }
zenc, err := zstd.NewWriter(buf)
if err != nil {
log.Panic(err)
}
err = zenc.Flush()
if err != nil {
log.Println(err)
}
// 发到对面的网卡
err = stream.Send(&gen.Request{
@ -259,14 +260,14 @@ func (nc *NetCard) runWrite() {
log.Printf("get wframes bytes len: %d", len(wframe))
var buf = bytes.NewBuffer(wframe)
// zdec, err := zstd.NewReader(buf)
// if err != nil {
// log.Panic(err)
// }
var zdec *zstd.Decoder
zdec, err = zstd.NewReader(buf)
if err != nil {
log.Panic(err)
}
zdec.Close()
// zdec.Close()
dec := gob.NewDecoder(buf)
dec := gob.NewDecoder(zdec)
var bufs [][]byte
err = dec.Decode(&bufs)
if err != nil {