ws

package
v0.0.0-...-b4573b1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCloseDeadline = 5 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnState

type ConnState uint8
const (
	ConnStateOpen ConnState = 1 << iota
	ConnStateListening
	ConnStateCloseReceived
	ConnStateCloseSent
	ConnStateClosed
	ConnStateError
)

type Connection

type Connection interface {
	ext.Conn
	CloseWithMsg(closeCode int, msg string) error
	Closed() bool
	ConnState() ConnState
	Listen() error
	ReadHandler() ReadHandler
	SetReadHandler(rh ReadHandler)
	Write(data []byte) (int, error)
}

func NewConnection

func NewConnection(conn ext.Conn, opts ConnectionOptions) (Connection, error)

type ConnectionOptions

type ConnectionOptions struct {
	CloseDeadline time.Duration
	CloseHandler  func(conn Connection, code int, text string) error
	PingHandler   func(conn Connection, appData string) error
	PongHandler   func(conn Connection, appData string) error
	// TODO: should be a duration and added to `now` before every operation
	ReadDeadline time.Time
	// ReadHandler handles new messages received on the websocket. If an error
	// is received the client MUST call `Close`. An error returned by ReadHandler
	// will be retured by `Listen`.
	ReadHandler ReadHandler
	// TODO: should be a duration and added to `now` before every operation
	WriteDeadline time.Time
	// Logger is an optional debug log writer.
	Logger Logger
}

type Logger

type Logger interface {
	Println(v ...interface{})
	Printf(format string, v ...interface{})
}

type ReadHandler

type ReadHandler func(conn Connection, messageType int, p []byte, err error) error

Directories

Path Synopsis
ext
extfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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