Versions in this module Expand all Collapse all v1 v1.0.0 Jan 5, 2022 Changes in this version + var RoomTitle = []string + var WsErrConnLoss = errors.New("conn already close") + func ClientIP(c *http.Request) string + func InitWsServer() + func NewPushTask(roomLen, workNum, taskNum int) + func NewRoomManage() + type PushJob struct + Info string + PushType int + RoomId int + Type int + type PushManage interface + Push func(job *PushJob) + func GetPushManage() PushManage + type PushTask struct + DistributionTask chan *PushJob + JobChan []chan *PushJob + func (p *PushTask) Push(job *PushJob) + type Room struct + RConn sync.Map + func (r *Room) Count() int + func (r *Room) JoinRoom(ws *WsConnection) error + func (r *Room) LeaveRoom(wsId string) error + func (r *Room) Push(msg *WSMessage) + type RoomManage struct + AllConn sync.Map + AllRoom sync.Map + func GetRoomManage() *RoomManage + func (r *RoomManage) AddConn(ws *WsConnection) + func (r *RoomManage) AddRoom(id int, wsId string) error + func (r *RoomManage) DelConn(ws *WsConnection) + func (r *RoomManage) LeaveRoom(id int, wsId string) error + func (r *RoomManage) NewRoom(id int, title string) error + func (r *RoomManage) PushAll(msg *WSMessage) + func (r *RoomManage) PushRoom(id int, msg *WSMessage) error + type WSMessage struct + Data string + Type int + type WsConnection struct + func NewWsConnection(conn *websocket.Conn) *WsConnection + func (w *WsConnection) CloseConn() + func (w *WsConnection) GetIp() string + func (w *WsConnection) GetWsId() string + func (w *WsConnection) ReadMsg() (message *WSMessage, err error) + func (w *WsConnection) SendMsg(msg *WSMessage) (err error) + func (w *WsConnection) SetIp(ip string) + func (w *WsConnection) WsHandle()