websocket

package
v0.0.7-beta Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2018 License: MIT Imports: 6 Imported by: 19

Documentation

Index

Constants

View Source
const (
	// PingInterval for the connection
	PingInterval = 25 * time.Second

	// PingTimeout for the connection
	PingTimeout = 60 * time.Second

	// ReadTimeout for the connection
	ReadTimeout = 60 * time.Second

	// SendTimeout for the connection
	SendTimeout = 60 * time.Second

	// BufferSize for the connection
	BufferSize = 1024 * 32
)

Variables

View Source
var (
	// ErrUnsupportedBinaryMessage is returned when trying to send an unsupported binary message
	ErrUnsupportedBinaryMessage = errors.New("sending binary messages is not supported")

	// ErrBadBuffer is used when there is an error while reading the buffer
	ErrBadBuffer = errors.New("error while reading buffer")

	// ErrPacketType is used when a packet comes with an unexpected format
	ErrPacketType = errors.New("wrong packet type")
)

Functions

This section is empty.

Types

type Connection

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

Connection to websocket

func (*Connection) Close

func (c *Connection) Close() error

Close the connection

func (*Connection) GetMessage

func (c *Connection) GetMessage() (data []byte, err error)

GetMessage on connection

func (*Connection) PingParams

func (c *Connection) PingParams() (interval, timeout time.Duration)

PingParams gets the ping and pong interval and timeout

func (*Connection) WriteMessage

func (c *Connection) WriteMessage(message string) error

WriteMessage to the socket

type Transport

type Transport struct {
	PingInterval time.Duration
	PingTimeout  time.Duration
	ReadTimeout  time.Duration
	SendTimeout  time.Duration

	BufferSize int

	Dialer        ws.Dialer
	RequestHeader http.Header
}

Transport for the websocket

func NewTransport

func NewTransport() *Transport

NewTransport creates a new WebSocket connection transport

func (*Transport) Connect

func (wst *Transport) Connect(url string) (conn *Connection, err error)

Connect to web socket with default gorilla websocket dialer

func (*Transport) ConnectContext

func (wst *Transport) ConnectContext(ctx context.Context, url string) (conn *Connection, err error)

ConnectContext to web socket with default gorilla websocket dialer

func (*Transport) ConnectDialer

func (wst *Transport) ConnectDialer(dialer ws.Dialer, url string) (conn *Connection, err error)

ConnectDialer to web socket

func (*Transport) ConnectDialerContext

func (wst *Transport) ConnectDialerContext(ctx context.Context, dialer ws.Dialer, url string) (conn *Connection, err error)

ConnectDialerContext to web socket

Jump to

Keyboard shortcuts

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