Configure MessagePack to be a bit more like gob

By default codec's MessagePack encode/decode will convert a string
into a []byte.  Tweak the settings so that string -> string and []byte
-> []byte.
This commit is contained in:
Julian Phillips 2014-05-11 14:36:16 +01:00
parent 2c0a7a501e
commit ee6a118090
2 changed files with 10 additions and 4 deletions

View file

@ -40,8 +40,11 @@ func newClientWithMux(mux *muxBroker, streamId uint32) (*Client, error) {
return nil, err
}
var h codec.MsgpackHandle
clientCodec := codec.GoRpc.ClientCodec(clientConn, &h)
h := &codec.MsgpackHandle{
RawToString: true,
WriteExt: true,
}
clientCodec := codec.GoRpc.ClientCodec(clientConn, h)
return &Client{
mux: mux,

View file

@ -148,8 +148,11 @@ func (s *Server) Serve() {
}
defer stream.Close()
var h codec.MsgpackHandle
rpcCodec := codec.GoRpc.ServerCodec(stream, &h)
h := &codec.MsgpackHandle{
RawToString: true,
WriteExt: true,
}
rpcCodec := codec.GoRpc.ServerCodec(stream, h)
s.server.ServeCodec(rpcCodec)
}