Skip to content

Commit

Permalink
Merge 72c2c29 into dc37adc
Browse files Browse the repository at this point in the history
  • Loading branch information
trey-jones committed Dec 20, 2017
2 parents dc37adc + 72c2c29 commit 9b0b1ed
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions jsonrpc2/client.go
Expand Up @@ -34,8 +34,8 @@ type clientCodec struct {
pending map[uint64]string // map request id to method name
}

// newClientCodec returns a new rpc.ClientCodec using JSON-RPC 2.0 on conn.
func newClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec {
// NewClientCodec returns a new rpc.ClientCodec using JSON-RPC 2.0 on conn.
func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec {
return &clientCodec{
dec: json.NewDecoder(conn),
enc: json.NewEncoder(conn),
Expand Down Expand Up @@ -223,7 +223,7 @@ func (c *clientCodec) Close() error {
// It also provides all methods of net/rpc Client.
type Client struct {
*rpc.Client
codec *clientCodec
codec rpc.ClientCodec
}

// Notify try to invoke the named function. It return error only in case
Expand All @@ -239,9 +239,15 @@ func (c Client) Notify(serviceMethod string, args interface{}) error {
// NewClient returns a new Client to handle requests to the
// set of services at the other end of the connection.
func NewClient(conn io.ReadWriteCloser) *Client {
codec := newClientCodec(conn)
codec := NewClientCodec(conn)
client := rpc.NewClientWithCodec(codec)
return &Client{client, codec.(*clientCodec)}
return &Client{client, codec}
}

// NewClientWithCodec returns a new Client using the given rpc.ClientCodec.
func NewClientWithCodec(codec rpc.ClientCodec) *Client {
client := rpc.NewClientWithCodec(codec)
return &Client{client, codec}
}

// Dial connects to a JSON-RPC 2.0 server at the specified network address.
Expand Down

0 comments on commit 9b0b1ed

Please sign in to comment.