Help us shape the future of Go! Take the 2026 Go Developer Survey

ws

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Upgrader = websocket.Upgrader{
	ReadBufferSize:  10240,
	WriteBufferSize: 10240,
	CheckOrigin: func(r *http.Request) bool {
		return true
	},
}

Upgrader 升级 HTTP 连接为 WebSocket 连接

Functions

This section is empty.

Types

type Config

type Config struct {
	WriteWait      time.Duration
	PingPeriod     time.Duration
	PongWait       time.Duration
	MaxMessageSize int64
}

Config 配置

type Transport

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

Transport WebSocket 传输

func New

func New(conn *websocket.Conn, cfgs ...Config) *Transport

New 创建一个新的 WebSocket 传输

func (*Transport) Close

func (t *Transport) Close() error

Close 关闭连接

func (*Transport) ReadMessage

func (t *Transport) ReadMessage() ([]byte, error)

ReadMessage 读取消息

func (*Transport) RemoteAddr

func (t *Transport) RemoteAddr() string

RemoteAddr 获取远程地址

func (*Transport) WriteMessage

func (t *Transport) WriteMessage(data []byte) error

WriteMessage 写入消息

Jump to

Keyboard shortcuts

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