websocket

package
v0.0.0-...-7a23388 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageNone = iota
	MessageText
	MessageBinary
)
View Source
const WSHeaderMinSize = 2

Variables

This section is empty.

Functions

func BuildWsPkt

func BuildWsPkt(pl []byte, code byte) []byte

Types

type Header struct {
	Fin    bool
	Rsv    byte
	OpCode byte
	Masked bool
	Mask   [4]byte
	Length int64
}

type UserDataHandler

type UserDataHandler interface {
	OnUserData(*WsCtx) []byte
}

type WsClient

type WsClient struct {
	Upgraded bool
	Cid      uint64

	AllowPlainHTTP bool
	PlainHTTP      bool

	UserData interface{}
	// contains filtered or unexported fields
}

type WsCtx

type WsCtx struct {
	Cid      uint64
	Data     []byte
	CallBack uint64
}

type WsHandler

type WsHandler struct {

	// EnablePlainHTTP allows a minimal HTTP response for non-WebSocket GET requests.
	// Default is false to preserve strict WebSocket-only behavior.
	EnablePlainHTTP bool
	// contains filtered or unexported fields
}

func (*WsHandler) OnClosed

func (ws *WsHandler) OnClosed(c connection.AppConn, err error)

func (*WsHandler) OnConnected

func (ws *WsHandler) OnConnected(c connection.ProtoConn)

func (*WsHandler) OnData

func (ws *WsHandler) OnData(c connection.ProtoConn, in *[]byte) (out []byte, close bool)

func (*WsHandler) ParsePacket

func (ws *WsHandler) ParsePacket(c connection.ProtoConn, in *[]byte) (length, expect int)

func (*WsHandler) SetUserDataHandler

func (ws *WsHandler) SetUserDataHandler(uh UserDataHandler)

func (*WsHandler) Stat

func (ws *WsHandler) Stat(bool)

Jump to

Keyboard shortcuts

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