faet: 新增WS模块

This commit is contained in:
TsMask
2024-01-23 18:06:44 +08:00
parent 413f0b4951
commit 89499c9d28
12 changed files with 673 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package model
import "github.com/gorilla/websocket"
// WSClient ws客户端
type WSClient struct {
ID string // 连接ID-随机字符串16位
Conn *websocket.Conn // 连接实例
LastHeartbeat int64 // 最近一次心跳消息(毫秒)
BindUid string // 绑定登录用户ID
SubGroup []string // 订阅组ID
MsgChan chan []byte // 消息通道
StopChan chan struct{} // 停止信号-退出协程
}
// WSRequest ws消息接收
type WSRequest struct {
Type string `json:"type"`
Data any `json:"data"`
}