websocket

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextMessage   = websocket.TextMessage
	BinaryMessage = websocket.BinaryMessage
	CloseMessage  = websocket.CloseMessage
	PingMessage   = websocket.PingMessage
	PongMessage   = websocket.PongMessage
)

Variables

This section is empty.

Functions

func RegisterSocketEndpoint

func RegisterSocketEndpoint(endpoint SocketEndpoint, middlewares ...func(*fiber.Ctx) error)

func Shutdown

func Shutdown(ctx context.Context) error

func SocketUpgradeHandler

func SocketUpgradeHandler(ctx *fiber.Ctx) error

func Start

func Start(ctx context.Context) error

Types

type Config

type Config struct {
	Websocket struct {
		BasePath           string `mapstructure:"base-path"`
		ContextPath        string `mapstructure:"context-path"`
		PingIntervalSecond int64  `mapstructure:"ping-interval-second"`
	} `mapstructure:"websocket"`
}

type EndpointAndHandlers

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

type SocketEndpoint

type SocketEndpoint interface {
	OnOpen(conn *WSConn) error
	OnClose(closeType int, message string) error
	OnMessage(*WSConn, string) error
	OnError(*WSConn, error)
	OnPing(message string) error
	OnPong(message string) error
	GetEndpointPath() string
}

type WSConn

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

func (*WSConn) Ctx

func (w *WSConn) Ctx() context.Context

func (*WSConn) Id

func (w *WSConn) Id() string

func (*WSConn) Interrupt

func (w *WSConn) Interrupt(err error)

func (*WSConn) WriteControl

func (w *WSConn) WriteControl(messageType int, message []byte, deadline time.Time) error

func (*WSConn) WriteJSON

func (w *WSConn) WriteJSON(v interface{}) error

func (*WSConn) WriteMessage

func (w *WSConn) WriteMessage(messageType int, data []byte) error

Jump to

Keyboard shortcuts

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