This commit is contained in:
黄思敏 2022-08-26 10:29:37 +08:00
parent 1b33e66799
commit 8042a498fe

View File

@ -76,16 +76,17 @@ func (cli *RPCClient) run() {
buf.Reset() buf.Reset()
// encode gob
enc := gob.NewEncoder(buf)
cliBuffer := <-cli.FrameChan
enc.Encode(cliBuffer.BytesArray)
// zstd compress
zenc, err := zstd.NewWriter(buf) zenc, err := zstd.NewWriter(buf)
if err != nil { if err != nil {
log.Panic(err) log.Panic(err)
} }
err = zenc.Close()
enc := gob.NewEncoder(zenc)
cliBuffer := <-cli.FrameChan
enc.Encode(cliBuffer.BytesArray)
err = zenc.Flush()
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }
@ -244,17 +245,15 @@ func (nc *NetCard) runWrite() {
if err != nil { if err != nil {
log.Panic(err) log.Panic(err)
} }
zdec.Close()
dec := gob.NewDecoder(zdec) dec := gob.NewDecoder(buf)
var bufs [][]byte var bufs [][]byte
err = dec.Decode(&bufs) err = dec.Decode(&bufs)
if err != nil { if err != nil {
log.Panic(err) log.Panic(err)
} }
zdec.Close()
for _, buf := range bufs { for _, buf := range bufs {
_, err := ifce.Write(buf) _, err := ifce.Write(buf)
if err != nil { if err != nil {