ws

package
v0.0.0-...-28537ac Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const BUF_SIZE_EXTEND = 1024 * 8
View Source
const MAX_BUF_SIZE = 1024 * 1024 * 512

Variables

View Source
var UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"

Functions

func WriteTextFrame

func WriteTextFrame(conn WSConn, text string) (int, error)

Types

type DialOptions

type DialOptions struct {
	Header http.Header
	TLS    *tls.Config
}

type RemoteAddresser

type RemoteAddresser interface {
	RemoteAddr() net.Addr
}

type Transport

type Transport interface {
	io.ReadWriteCloser
	RemoteAddresser
}

func MakeTransport

func MakeTransport(conn WSConn) Transport

type WSConn

type WSConn interface {
	ReadFrame() (*WSFrame, error)
	WriteFrame(*WSFrame) (int, error)
	WriteFrames([]*WSFrame) (int, error)
	io.Closer
	RemoteAddresser
}

func Dial

func Dial(uriStr string) (WSConn, error)

func DialWithOptions

func DialWithOptions(uriStr string, options *DialOptions) (WSConn, error)

func WebSocketHandshake

func WebSocketHandshake(req *http.Request, w http.ResponseWriter) (WSConn, error)

type WSFrame

type WSFrame struct {
	Fin  bool
	Op   uint8
	Data []byte
}

func NewBinaryFrame

func NewBinaryFrame(dat []byte) *WSFrame

func NewTextFrame

func NewTextFrame(text string) *WSFrame

Jump to

Keyboard shortcuts

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