websocketclient

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL