Documentation ¶
Index ¶
- Variables
- type Client
- type Error
- type HTTPTransport
- type Transport
- type WebsocketTransport
- func (h *WebsocketTransport) Call(method string, args interface{}, reply interface{}) error
- func (h *WebsocketTransport) Context() context.Context
- func (h *WebsocketTransport) Subscribe(method string, notifyMethod string, args interface{}, reply interface{}) (chan json.RawMessage, chan *Error, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrConnClosed = errors.New("connection closed")
ErrConnClosed error for connection closed
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // URL is remote url, // example // http://username:password@192.168.1.3:1001/jsonrpc // ws://192.168.0.1:9121/ URL string Transport Transport }
Client json rpc client
type Error ¶
type Error struct { Code int `json:"code"` Message string `json:"message"` Data json.RawMessage `json:"data"` }
Error rpc error
type HTTPTransport ¶
type HTTPTransport struct { Client *http.Client URL string Mu *sync.Mutex // contains filtered or unexported fields }
HTTPTransport json rpc over http
func (*HTTPTransport) Call ¶
func (h *HTTPTransport) Call(method string, args interface{}, reply interface{}) error
Call call a remote method
func (*HTTPTransport) Subscribe ¶
func (h *HTTPTransport) Subscribe(method string, notifyMethod string, args interface{}, reply interface{}) (chan json.RawMessage, chan *Error, error)
Subscribe subscribe for change
type Transport ¶
type Transport interface { Call(method string, args interface{}, reply interface{}) error Subscribe(method string, notifyMethod string, args interface{}, reply interface{}) (chan json.RawMessage, chan *Error, error) }
Transport json rpc transport
func NewHTTPTransport ¶
NewHTTPTransport create a new http transport
type WebsocketTransport ¶
type WebsocketTransport struct { Conn *websocket.Conn URL string Mu *sync.Mutex // contains filtered or unexported fields }
WebsocketTransport json rpc over websocket
func (*WebsocketTransport) Call ¶
func (h *WebsocketTransport) Call(method string, args interface{}, reply interface{}) error
Call call a remote method
func (*WebsocketTransport) Context ¶
func (h *WebsocketTransport) Context() context.Context
Context return the context transport used
func (*WebsocketTransport) Subscribe ¶
func (h *WebsocketTransport) Subscribe(method string, notifyMethod string, args interface{}, reply interface{}) (chan json.RawMessage, chan *Error, error)
Subscribe subscribe for change
Click to show internal directories.
Click to hide internal directories.