gowebsocket

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

go-websocket

Fork of sac007/GoWebsocket

This fork addresses hotfixes and major improvements, as well as auto-reconnect. This README is left intentionally blank as I will not support this project, for now. Do not attempt to use as it contains breaking changes.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildProxy

func BuildProxy(Url string) func(*http.Request) (*url.URL, error)

Types

type ConnectionOptions

type ConnectionOptions struct {
	UseCompression bool
	UseSSL         bool
	Proxy          func(*http.Request) (*url.URL, error)
	SubProtocols   []string
	AutoRetry      bool
	RetryDelay     time.Duration
}

type Logger

type Logger interface {
	Errorf(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Tracef(format string, args ...interface{})
}

type NoOpLogger

type NoOpLogger struct {
}

func (NoOpLogger) Debugf

func (n NoOpLogger) Debugf(_ string, _ ...interface{})

func (NoOpLogger) Errorf

func (n NoOpLogger) Errorf(_ string, _ ...interface{})

func (NoOpLogger) Infof

func (n NoOpLogger) Infof(_ string, _ ...interface{})

func (NoOpLogger) Tracef

func (n NoOpLogger) Tracef(_ string, _ ...interface{})

func (NoOpLogger) Warnf

func (n NoOpLogger) Warnf(_ string, _ ...interface{})

type ReconnectionOptions

type ReconnectionOptions struct {
	AutoRetry  bool
	RetryDelay time.Duration
}

type Socket

type Socket struct {
	Conn            *websocket.Conn
	WebsocketDialer *websocket.Dialer
	Url             string
	Connection      ConnectionOptions
	Reconnection    ReconnectionOptions
	RequestHeader   http.Header
	OnConnected     func(socket Socket)
	OnTextMessage   func(message string, socket Socket)
	OnBinaryMessage func(data []byte, socket Socket)
	Log             Logger
	Timeout         time.Duration
	OnConnectError  func(err error, socket Socket)
	OnDisconnected  func(err error, socket Socket)
	OnPingReceived  func(data string, socket Socket)
	OnPongReceived  func(data string, socket Socket)
	// contains filtered or unexported fields
}

func New

func New(url string) Socket

func (*Socket) Close

func (socket *Socket) Close()

func (*Socket) Connect

func (socket *Socket) Connect(ctx context.Context)

func (*Socket) IsConnected

func (socket *Socket) IsConnected() bool

func (*Socket) SendBinary

func (socket *Socket) SendBinary(data []byte)

func (*Socket) SendText

func (socket *Socket) SendText(message string)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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