Documentation ¶
Index ¶
- type WebsocketClient
- 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) SetCacheValidTime(validTime time.Duration)
- 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 Chia RPC via websockets
func NewWebsocketClient ¶
func NewWebsocketClient(cfg *config.ChiaConfig, options ...rpcinterface.ClientOptionFunc) (*WebsocketClient, error)
NewWebsocketClient returns a new websocket client that satisfies the rpcinterface.Client interface
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) SetCacheValidTime ¶
func (c *WebsocketClient) SetCacheValidTime(validTime time.Duration)
SetCacheValidTime sets how long cache should be valid for This is not currently supported by the websocket client
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 Chia This call will subscribe `go-chia-rpc` origin for any requests we specifically make of the server