websocket

package
v0.0.0-...-88db892 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Socket

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

func New

func New(url url.URL, options ...WebsocketOption) *Socket

func (*Socket) Close

func (s *Socket) Close(ctx context.Context)

func (*Socket) Connect

func (s *Socket) Connect()

func (*Socket) IsConnected

func (s *Socket) IsConnected() bool

func (*Socket) SendBinary

func (s *Socket) SendBinary(ctx context.Context, data []byte) error

func (*Socket) SendText

func (s *Socket) SendText(ctx context.Context, message string) error

func (*Socket) Stop

func (s *Socket) Stop()

type WebsocketOption

type WebsocketOption func(s *Socket)

func WithConfigFile

func WithConfigFile(filePath string) WebsocketOption

func WithHeaders

func WithHeaders(headers http.Header) WebsocketOption

func WithOnClose

func WithOnClose(f func(code int, reason string)) WebsocketOption

func WithOnConnect

func WithOnConnect(f func(socket *Socket)) WebsocketOption

func WithOnError

func WithOnError(f func(err error, socket *Socket)) WebsocketOption

func WithOnMessage

func WithOnMessage(f func(messageType int, data []byte, socket *Socket)) WebsocketOption

func WithOnNoReconnect

func WithOnNoReconnect(f func(attemp int, socket *Socket)) WebsocketOption

func WithOnPingReceived

func WithOnPingReceived(f func(data string, socket *Socket)) WebsocketOption

func WithOnPongReceived

func WithOnPongReceived(f func(data string, socket *Socket)) WebsocketOption

func WithOnReconnect

func WithOnReconnect(f func(attempt int, delay time.Duration, socket *Socket)) WebsocketOption

func WithProxy

func WithProxy(f func(*http.Request) (*url.URL, error)) WebsocketOption

Jump to

Keyboard shortcuts

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