websocket

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultManager = NewManager()

DefaultManager 默认管理器

Functions

This section is empty.

Types

type Key

type Key interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~string
}

type Manager

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

Manager websocket管理器

func NewManager

func NewManager() *Manager

func (*Manager) AddConnect

func (wm *Manager) AddConnect(key any, conn *websocket.Conn)

AddConnect 添加一条网络连接

func (*Manager) ConnectCount

func (wm *Manager) ConnectCount() uint64

ConnectCount 所以网络连接数量

func (*Manager) KeysCount

func (wm *Manager) KeysCount() uint64

KeysCount 获取所有键数量

func (*Manager) PushData added in v1.0.5

func (wm *Manager) PushData(data any, keys ...any)

PushData 推送传入的对象进行解析,并发到各个ws连接上

func (*Manager) PushMessage

func (wm *Manager) PushMessage(msg []byte, keys ...any)

PushMessage 推送消息到网络连接上

func (*Manager) RemoveConnect

func (wm *Manager) RemoveConnect(key string, conn *websocket.Conn)

RemoveConnect 删除一条网络连接

type Payload

type Payload struct {
	// Type 类型
	Type string `json:"type"`

	// Data 具体数据
	Data any `json:"data"`
}

Payload 用于websocket的推送数据结构

Jump to

Keyboard shortcuts

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