diff --git a/client.go b/client.go index 928bc35..e65e36f 100644 --- a/client.go +++ b/client.go @@ -203,12 +203,20 @@ func (c *Client) Send(data []byte) error { // RPC allows to make RPC – send data to server ant wait for response. // RPC handler must be registered on server. func (c *Client) RPC(data []byte) ([]byte, error) { + return c.NamedRPC("", data) +} + +// NamedRPC allows to make RPC – send data to server ant wait for response. +// RPC handler must be registered on server. +// In contrast to RPC method it allows to pass method name. +func (c *Client) NamedRPC(method string, data []byte) ([]byte, error) { cmd := &protocol.Command{ ID: c.nextMsgID(), Method: protocol.MethodTypeRPC, } params := &protocol.RPCRequest{ - Data: data, + Data: data, + Method: method, } paramsData, err := c.paramsEncoder.Encode(params) if err != nil { diff --git a/examples/go.sum b/examples/go.sum index c6a5bda..aafd3d9 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -2,6 +2,8 @@ github.com/centrifugal/protocol v0.3.0 h1:4W9TKybntVlAfMkf54vtmbrZ9dcLHynqiw93vf github.com/centrifugal/protocol v0.3.0/go.mod h1:2YbBCaDwQHl37ErRdMrKSj18X2yVvpkQYtSX6aVbe5A= github.com/centrifugal/protocol v0.3.1 h1:6/+seAUMDF8Z6QuI/vCtiKGJZw8qatdOXal3DALeU00= github.com/centrifugal/protocol v0.3.1/go.mod h1:2YbBCaDwQHl37ErRdMrKSj18X2yVvpkQYtSX6aVbe5A= +github.com/centrifugal/protocol v0.3.3 h1:GCNee3RFsjQu6SyKBX0Ir7ByUrp+Gw0MU/PsIc2CM2s= +github.com/centrifugal/protocol v0.3.3/go.mod h1:2YbBCaDwQHl37ErRdMrKSj18X2yVvpkQYtSX6aVbe5A= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= @@ -10,6 +12,8 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/jpillora/backoff v0.0.0-20170918002102-8eab2debe79d h1:ix3WmphUvN0GDd0DO9MH0v6/5xTv+Xm1bPN+1UJn58k= github.com/jpillora/backoff v0.0.0-20170918002102-8eab2debe79d/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0= +github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=