websocket

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDialTimeout           = 30 * time.Second
	DefaultAutoReconnectMaxDelay = 5 * time.Minute
)

Variables

View Source
var (
	ErrClosing = errors.New("closing")
)

Functions

This section is empty.

Types

type ConnectedEvent added in v0.2.0

type ConnectedEvent struct {
	URL string
}

ConnectedEvent is emitted when the WebSocket connection is established.

func (*ConnectedEvent) String added in v0.2.0

func (e *ConnectedEvent) String() string

type ConnectingEvent added in v0.2.0

type ConnectingEvent struct {
	URL string
}

ConnectingEvent is emitted when a new connection is being established.

func (*ConnectingEvent) String added in v0.2.0

func (e *ConnectingEvent) String() string

type DialTimeoutEvent added in v0.2.0

type DialTimeoutEvent struct {
	URL     string
	Err     error
	Timeout time.Duration
}

DialTimeoutEvent is emitted when establishing a new connection times out.

func (*DialTimeoutEvent) String added in v0.2.0

func (e *DialTimeoutEvent) String() string

type DisconnectedEvent added in v0.2.0

type DisconnectedEvent struct {
	URL string
	Err error
}

DisconnectedEvent is emitted when the WebSocket connection is lost.

func (*DisconnectedEvent) String added in v0.2.0

func (e *DisconnectedEvent) String() string

type Option added in v0.2.0

type Option func(*Transport)

Option represents an option that can be passed into the transport constructor.

func SetAutoReconnectEnabled added in v0.2.0

func SetAutoReconnectEnabled(enabled bool) Option

SetAutoReconnectEnabled can be used to enable automatic reconnection to the RPC endpoint. Exponential backoff is used when the connection cannot be established repetitively.

See SetAutoReconnectMaxDelay to set the maximum delay between the reconnection attempts.

func SetAutoReconnectMaxDelay added in v0.2.0

func SetAutoReconnectMaxDelay(delay time.Duration) Option

SetAutoReconnectMaxDelay can be used to set the maximum delay between the reconnection attempts.

This option only takes effect when the auto-reconnect mode is enabled.

The default value is 5 minutes.

func SetDialTimeout added in v0.2.0

func SetDialTimeout(timeout time.Duration) Option

SetDialTimeout can be used to set the timeout when establishing a new connection.

func SetMonitor added in v0.2.0

func SetMonitor(monitorChan chan<- interface{}) Option

SetMonitor can be used to set the monitoring channel that can be used to watch connection-related state changes.

All channel send operations are happening synchronously, so not receiving messages from the channel will lead to the whole thing getting stuck completely.

This option only takes effect when the auto-reconnect mode is enabled.

The channel is closed when the transport is closed.

func SetReadTimeout added in v0.2.0

func SetReadTimeout(timeout time.Duration) Option

SetReadTimeout sets the connection read timeout. The timeout is implemented using net.Conn.SetReadDeadline.

func SetReadWriteTimeout added in v0.2.0

func SetReadWriteTimeout(timeout time.Duration) Option

SetReadWriteTimeout sets the connection read and write timeout. The timeout is implemented using net.Conn.SetDeadline.

func SetWriteTimeout added in v0.2.0

func SetWriteTimeout(timeout time.Duration) Option

SetWriteTimeout sets the connection read timeout. The timeout is implemented using net.Conn.SetWriteDeadline.

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport implements a CallCloser accessing the Steem RPC endpoint over WebSocket.

func NewTransport added in v0.2.0

func NewTransport(endpointURL string, options ...Option) (*Transport, error)

NewTransport creates a new transport that connects to the given WebSocket URL.

func (*Transport) Call

func (t *Transport) Call(method string, params, response interface{}) error

Call implements interfaces.CallCloser.

func (*Transport) Close

func (t *Transport) Close() error

Close implements interfaces.CallCloser.

Jump to

Keyboard shortcuts

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