ws

package
v1.0.2-0...-2da3d3e Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

An abstraction for sending out to websocket using channels.

func NewClient

func NewClient(conn WSReadWriter) *Client

Creates a new websocket client.

func NewClientWithID

func NewClientWithID(conn WSReadWriter, id string) *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) ID

func (c *Client) ID() string

func (*Client) Metadata

func (c *Client) Metadata() string

func (*Client) SetMetadata

func (c *Client) SetMetadata(metadata string)

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, handle func(wsmessage.Message)) error

func (*Client) WriteChannel

func (c *Client) WriteChannel() chan<- wsmessage.Message

Gets the channel to write out to. Messages sent here will be written to the websocket and received by the other side.

func (*Client) WriteTimeout

func (c *Client) WriteTimeout(ctx context.Context, timeout time.Duration, msg wsmessage.Message) error

Writes a message to websocket with timeout.

type WSReadWriter

type WSReadWriter interface {
	WSReader
	WSWriter
}

type WSReader

type WSReader interface {
	Read(ctx context.Context) (websocket.MessageType, []byte, error)
}

type WSWriter

type WSWriter interface {
	Write(ctx context.Context, typ websocket.MessageType, msg []byte) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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