Documentation ¶
Index ¶
- type WebsocketClient
- func (c *WebsocketClient) AddDisconnectHandler(onDisconnect rpcinterface.DisconnectHandler)
- func (c *WebsocketClient) AddReconnectHandler(onReconnect rpcinterface.ReconnectHandler)
- func (c *WebsocketClient) Do(req *rpcinterface.Request, v interface{}) (*http.Response, error)
- func (c *WebsocketClient) ListenSync(handler rpcinterface.WebsocketResponseHandler) error
- func (c *WebsocketClient) NewRequest(service rpcinterface.ServiceType, rpcEndpoint rpcinterface.Endpoint, ...) (*rpcinterface.Request, error)
- func (c *WebsocketClient) SetBaseURL(url *url.URL) error
- func (c *WebsocketClient) Subscribe(service string) error
- func (c *WebsocketClient) SubscribeSelf() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WebsocketClient ¶
type WebsocketClient struct {
// contains filtered or unexported fields
}
WebsocketClient connects to Chik RPC via websockets
func NewWebsocketClient ¶
func NewWebsocketClient(cfg *config.ChikConfig, options ...rpcinterface.ClientOptionFunc) (*WebsocketClient, error)
NewWebsocketClient returns a new websocket client that satisfies the rpcinterface.Client interface
func (*WebsocketClient) AddDisconnectHandler ¶
func (c *WebsocketClient) AddDisconnectHandler(onDisconnect rpcinterface.DisconnectHandler)
AddDisconnectHandler the function to call when the client is disconnected
func (*WebsocketClient) AddReconnectHandler ¶
func (c *WebsocketClient) AddReconnectHandler(onReconnect rpcinterface.ReconnectHandler)
AddReconnectHandler the function to call when the client is reconnected after a disconnect
func (*WebsocketClient) Do ¶
func (c *WebsocketClient) Do(req *rpcinterface.Request, v interface{}) (*http.Response, error)
Do sends an RPC request via the websocket *http.Response is always nil in this return, and exists to satisfy the interface that existed prior to websockets being supported in this library
func (*WebsocketClient) ListenSync ¶
func (c *WebsocketClient) ListenSync(handler rpcinterface.WebsocketResponseHandler) error
ListenSync Listens for responses over the websocket connection in the foreground The error returned from this function would only correspond to an error setting up the listener Errors returned by ReadMessage, or some other part of the websocket request/response will be passed to the handler to deal with
func (*WebsocketClient) NewRequest ¶
func (c *WebsocketClient) NewRequest(service rpcinterface.ServiceType, rpcEndpoint rpcinterface.Endpoint, opt interface{}) (*rpcinterface.Request, error)
NewRequest creates an RPC request for the specified service
func (*WebsocketClient) SetBaseURL ¶
func (c *WebsocketClient) SetBaseURL(url *url.URL) error
SetBaseURL sets the base URL for API requests to a custom endpoint.
func (*WebsocketClient) Subscribe ¶
func (c *WebsocketClient) Subscribe(service string) error
Subscribe adds a subscription to a particular service
func (*WebsocketClient) SubscribeSelf ¶
func (c *WebsocketClient) SubscribeSelf() error
SubscribeSelf calls subscribe for any requests that this client makes to the server Different from Subscribe with a custom service - that is more for subscribing to built in events emitted by Chik This call will subscribe `go-chik-rpc` origin for any requests we specifically make of the server