Skip to content

Commit

Permalink
- fix server sync write coder middlewares
Browse files Browse the repository at this point in the history
  • Loading branch information
lesismal committed Aug 3, 2021
1 parent 8d0879b commit cf8ae47
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,19 @@ func (ctx *Context) writeDirectly(v interface{}, isError bool) error {
isError = true
}
rsp := newMessage(CmdResponse, req.method(), v, isError, req.IsAsync(), req.Seq(), cli.Handler, cli.Codec, ctx.values)
_, err := cli.Conn.Write(rsp.Buffer)
return err
if !cli.reconnecting {
coders := cli.Handler.Coders()
for j := 0; j < len(coders); j++ {
rsp = coders[j].Encode(cli, rsp)
}
_, err := cli.Handler.Send(cli.Conn, rsp.Buffer)
if err != nil {
cli.Conn.Close()
}
return err
}
cli.dropMessage(rsp)
return ErrClientReconnecting
}

func newContext(cli *Client, msg *Message, handlers []HandlerFunc) *Context {
Expand Down

0 comments on commit cf8ae47

Please sign in to comment.