websocket

package
v0.0.0-...-51fd5d7 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextMessage   = 1
	BinaryMessage = 2
	CloseMessage  = 8
	PingMessage   = 9
	PongMessage   = 10
)

declare message types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Close closes the connection.
	// It's safe to call multiple times.
	Close()
	// OnClose is called when the
	// connection is closed.
	OnClose(func())
	// OnMessageRecv is called when a
	// message is received. It must be
	// a non-blocking function.
	OnMessageRecv(func(int, []byte))
	// Write a message to the client.
	Write(int, []byte)
}

WebSocket client.

type ClientConfig

type ClientConfig struct {
	// writeTimeout is the timeout
	// to close the connection if
	// message not writed.
	WriteTimeout time.Duration
	// pingInterval is the interval
	// between each ping. If value
	// is <= 0 the server will not
	// send ping messages.
	PingInterval time.Duration
	// maxMessageLength is the max
	// number of bytes in a client
	// message. Connection will be
	// closed if exceeded.
	MaxMessageLength int
}

type Manager

type Manager struct {
	// Log is the logger.
	Log *logger.Logger
	// contains filtered or unexported fields
}

func (*Manager) Close

func (x *Manager) Close()

func (*Manager) NewClient

func (x *Manager) NewClient(upgrader websocket.Upgrader, c *gin.Context, config ClientConfig) (Client, error)

Jump to

Keyboard shortcuts

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