client

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Close() error
	CloseWithCode(code websocket.StatusCode, reason string) error
	OnWithAck(event string, f func(data []byte) []byte) Client
	Dial(ctx context.Context, url string) error
	Ping(ctx context.Context) error
	// If registered, all unknown events will be handled here.
	OnDefault(f func(event string, data []byte)) Client
	On(event string, f func(data []byte)) Client
	Unsubscribe(event string) Client
	OnConnect(f func()) Client
	OnDisconnect(f func(error)) Client
	OnError(f func(error)) Client
	Emit(ctx context.Context, event string, body []byte) error
	EmitWithAck(ctx context.Context, event string, body []byte) ([]byte, error)
	Closed() bool
}

func NewClient

func NewClient(config Config) Client

type Config

type Config struct {
	// By default, the connection has a message read limit of 32768 bytes.
	// When the limit is hit, the connection will be closed with StatusMessageTooBig.
	ConnectionReadLimit int64
	// May be nil
	HttpClient *http.Client
	// May be nil
	HttpHeaders http.Header
	// Default is defaultWorkersNum
	WorkersNum int
	// Default is defaultWorkersBufferMultiplier
	WorkersBufferMultiplier int
}

Jump to

Keyboard shortcuts

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