Documentation ¶
Index ¶
- func DecodeMsg(msg *pstypes.WebSocketMessage) (interface{}, error)
- func DecodeMsgInt(msg *pstypes.WebSocketMessage) (int, error)
- func DecodeMsgMempool(msg *pstypes.WebSocketMessage) (*exptypes.MempoolShort, error)
- func DecodeMsgNewAddressTx(msg *pstypes.WebSocketMessage) (*pstypes.AddressMessage, error)
- func DecodeMsgNewBlock(msg *pstypes.WebSocketMessage) (*exptypes.WebsocketBlock, error)
- func DecodeMsgPing(msg *pstypes.WebSocketMessage) (int, error)
- func DecodeMsgString(msg *pstypes.WebSocketMessage) (string, error)
- func DecodeMsgTxList(msg *pstypes.WebSocketMessage) (*pstypes.TxList, error)
- func DecodeResponseMsg(msg *pstypes.WebSocketMessage) (*pstypes.ResponseMessage, error)
- func DisableLog()
- func UseLogger(logger slog.Logger)
- func Version() semver.Semver
- type Client
- func (c *Client) Ping() error
- func (c *Client) Receive() <-chan *ClientMessage
- func (c *Client) ServerVersion() (*pstypes.Ver, error)
- func (c *Client) Stop()
- func (c *Client) Subscribe(event string) (*pstypes.ResponseMessage, error)
- func (c *Client) Unsubscribe(event string) (*pstypes.ResponseMessage, error)
- type ClientMessage
- type Opts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeMsg ¶
func DecodeMsg(msg *pstypes.WebSocketMessage) (interface{}, error)
DecodeMsg attempts to decode the Message content of the given WebSocketMessage based on its EventId. The type contained in the returned interface{} depends on the EventId.
func DecodeMsgInt ¶
func DecodeMsgInt(msg *pstypes.WebSocketMessage) (int, error)
DecodeMsgInt attempts to decode the Message content of the given WebSocketMessage as an int.
func DecodeMsgMempool ¶
func DecodeMsgMempool(msg *pstypes.WebSocketMessage) (*exptypes.MempoolShort, error)
DecodeMsgMempool attempts to decode the Message content of the given WebSocketMessage as a mempool message (*exptypes.MempoolShort).
func DecodeMsgNewAddressTx ¶
func DecodeMsgNewAddressTx(msg *pstypes.WebSocketMessage) (*pstypes.AddressMessage, error)
DecodeMsgNewAddressTx attempts to decode the Message content of the given WebSocketMessage as an address message (*DecodeMsgNewAddressTx).
func DecodeMsgNewBlock ¶
func DecodeMsgNewBlock(msg *pstypes.WebSocketMessage) (*exptypes.WebsocketBlock, error)
DecodeMsgNewBlock attempts to decode the Message content of the given WebSocketMessage as a newblock message (*exptypes.WebsocketBlock).
func DecodeMsgPing ¶
func DecodeMsgPing(msg *pstypes.WebSocketMessage) (int, error)
DecodeMsgPing attempts to decode the Message content of the given WebSocketMessage ping response message (int).
func DecodeMsgString ¶
func DecodeMsgString(msg *pstypes.WebSocketMessage) (string, error)
DecodeMsgString attempts to decode the Message content of the given WebSocketMessage as a string.
func DecodeMsgTxList ¶
func DecodeMsgTxList(msg *pstypes.WebSocketMessage) (*pstypes.TxList, error)
DecodeMsgTxList attempts to decode the Message content of the given WebSocketMessage as a newtxs message (*pstypes.TxList).
func DecodeResponseMsg ¶
func DecodeResponseMsg(msg *pstypes.WebSocketMessage) (*pstypes.ResponseMessage, error)
DecodeResponseMsg attempts to decode the Message content of the given WebSocketMessage as a request response message (string).
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
Types ¶
type Client ¶
Client wraps a *websocket.Conn.
func NewFromConn ¶
NewFromConn creates a new Client from a *websocket.Conn.
func (*Client) Receive ¶
func (c *Client) Receive() <-chan *ClientMessage
Receive gets a receive-only *ClientMessage channel, through which all messages from the server to the client should be received.
func (*Client) ServerVersion ¶
ServerVersion sends a server version query, and returns the response.
func (*Client) Stop ¶
func (c *Client) Stop()
Stop shutsdown the Client. If the websocket connection was created during Client construction, it is is shutdown too.
func (*Client) Subscribe ¶
func (c *Client) Subscribe(event string) (*pstypes.ResponseMessage, error)
Subscribe sends a subscribe type WebSocketMessage for the given event name after validating it. The response is returned.
func (*Client) Unsubscribe ¶
func (c *Client) Unsubscribe(event string) (*pstypes.ResponseMessage, error)
Unsubscribe sends an unsubscribe type WebSocketMessage for the given event name after validating it. The response is returned.
type ClientMessage ¶
type ClientMessage struct { EventId string Message interface{} }
ClientMessage represents a message for a client connection. The (*Client).Receive method provides a channel such messages from the server.