client

package
v0.0.0-...-775ef2c Latest Latest
Warning

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

Go to latest
Published: May 19, 2019 License: ISC Imports: 6 Imported by: 1

Documentation

Index

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 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) (string, error)

DecodeMsgPing attempts to decode the Message content of the given WebSocketMessage ping response message (string).

func DecodeMsgString

func DecodeMsgString(msg *pstypes.WebSocketMessage) (string, error)

DecodeMsgString attempts to decode the Message content of the given WebSocketMessage as a string.

func DecodeMsgSubscribeResponse

func DecodeMsgSubscribeResponse(msg *pstypes.WebSocketMessage) (string, error)

DecodeMsgSubscribeResponse attempts to decode the Message content of the given WebSocketMessage as a subscribe response message (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 DecodeMsgUnsubscribeResponse

func DecodeMsgUnsubscribeResponse(msg *pstypes.WebSocketMessage) (string, error)

DecodeMsgUnsubscribeResponse attempts to decode the Message content of the given WebSocketMessage as an unsubscribe response message (string).

Types

type Client

type Client struct {
	*websocket.Conn
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

Client wraps a *websocket.Conn.

func New

func New(ws *websocket.Conn) *Client

New creates a new Client from a *websocket.Conn.

func (*Client) ReceiveMsg

func (c *Client) ReceiveMsg() (*pstypes.WebSocketMessage, error)

ReceiveMsg waits for a message, returned decoded into a WebSocketMessage. The Client's configured ReadTimeout is used.

func (*Client) ReceiveMsgTimeout

func (c *Client) ReceiveMsgTimeout(timeout time.Duration) (*pstypes.WebSocketMessage, error)

ReceiveMsgTimeout waits for the specified time Duration for a message, returned decoded into a WebSocketMessage.

func (*Client) ReceiveRaw

func (c *Client) ReceiveRaw() (message string, err error)

ReceiveRaw for a message, returned undecoded as a string.

func (*Client) Subscribe

func (c *Client) Subscribe(event string) (*pstypes.WebSocketMessage, 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.WebSocketMessage, error)

Unsubscribe sends an unsubscribe type WebSocketMessage for the given event name after validating it. The response is returned.

Jump to

Keyboard shortcuts

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