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