websocket

package
v0.4.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	WsServerStatusClose     = 0 //连接关闭
	WsServerStatusOpen      = 1 //连接开启
	WsServerStatusBeClosing = 2 //连接正在关闭
)

Variables

View Source
var (
	DataFramesDefault = []byte{} //默认数据帧

)

Functions

func Check

func Check(fd uint64) (ok bool)

func Disconnect

func Disconnect(fd uint64, data []byte)

断开连接

func Push

func Push(fd uint64, data any)

推送消息

func RemoveServer

func RemoveServer(ser *WsServer)

func Start

func Start()

Types

type ConnWriteChanParams added in v0.3.17

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

type Sender

type Sender struct {
	sync.Map
}

type WsServer

type WsServer struct {
	Ctx                   *fasthttp.RequestCtx
	Conn                  *websocket.Conn
	ConnWriteChan         chan *ConnWriteChanParams
	Fd                    uint64
	MessageType           int
	LastResponseTimestamp int64
	Status                byte
}

func SetServer

func SetServer(ctx *fasthttp.RequestCtx) (ser *WsServer)

func (*WsServer) Check

func (s *WsServer) Check() bool

func (*WsServer) Disconnect

func (s *WsServer) Disconnect(data []byte)

主动断开连接

func (*WsServer) OnClose added in v0.3.30

func (s *WsServer) OnClose()

连接断开事件处理

func (*WsServer) Ping added in v0.3.17

func (s *WsServer) Ping(data []byte, deadline time.Time)

func (*WsServer) Pong added in v0.3.17

func (s *WsServer) Pong(data []byte, deadline time.Time)

func (*WsServer) Push

func (s *WsServer) Push(data any)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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