feat: implement codec

This commit is contained in:
2022-04-22 20:50:58 +08:00
parent 9083504cfc
commit cf8fa335a6
9 changed files with 332 additions and 0 deletions

18
response.go Normal file
View File

@ -0,0 +1,18 @@
package krpc
import (
"fmt"
"sync"
"krwu.top/krpc.v1/codec"
)
func (s *Server) sendResponse(cc codec.Codec, h *codec.Header, body interface{}, sending *sync.Mutex) {
sending.Lock()
defer sending.Unlock()
if err := cc.Write(h, body); err != nil {
fmt.Println("rpc server: write response error: ", err)
}
}