1 Star 0 Fork 0

玟兵 / go-util

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
init.go 775 Bytes
一键复制 编辑 原始数据 按行查看 历史
玟兵 提交于 2024-04-30 22:31 . 细节优化
package ws
import (
"github.com/gorilla/websocket"
"net/http"
"time"
)
type Message struct {
Sender string `json:"sender,omitempty"`
Recipients []string `json:"recipients,omitempty"`
Groups []string `json:"groups,omitempty"`
Content any `json:"content,omitempty"`
}
type Client struct {
Id string
Groups []string
Hub *Hub
Conn *websocket.Conn
Send chan *Message
}
type Hub struct {
Clients map[string]*Client
Broadcast chan *Message
Register chan *Client
Unregister chan *Client
}
const (
writeWait = 10 * time.Second
pongWait = 60 * time.Second
pingPeriod = 55 * time.Second
maxMessageSize = 2048
)
var _upgrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
Go
1
https://gitee.com/binny_w/go-util.git
git@gitee.com:binny_w/go-util.git
binny_w
go-util
go-util
v0.0.19

搜索帮助