websocketclient

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 17 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 {

	// Request timeout
	Timeout time.Duration
	// 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) AddHandler added in v0.7.0

AddHandler Adds a new handler function and returns its UUID for removing it later or an error

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 in async mode call SetSyncMode() to ensure the calls return the data in a synchronous fashion

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) RemoveHandler added in v0.7.0

func (c *WebsocketClient) RemoveHandler(handlerID uuid.UUID)

RemoveHandler removes the handler from the list of active response handlers

func (*WebsocketClient) SetAsyncMode added in v0.7.0

func (c *WebsocketClient) SetAsyncMode()

SetAsyncMode sets the client to async mode (default) RPC method calls return empty versions of the response objects, and you must have your own listeners to get the responses and handle them

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) SetLogHandler added in v0.7.0

func (c *WebsocketClient) SetLogHandler(handler slog.Handler)

SetLogHandler sets a slog compatible log handler

func (*WebsocketClient) SetSyncMode added in v0.7.0

func (c *WebsocketClient) SetSyncMode()

SetSyncMode enforces synchronous request/response behavior RPC method calls return the actual expected RPC response when this mode is enabled

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