Documentation ¶
Index ¶
- type Hub
- func (h *Hub) Add(clientId string, wsChan *WsChannal)
- func (h *Hub) AddGroup(groupId string, wsChan *WsChannal)
- func (h *Hub) All() []*WsChannal
- func (h *Hub) Closed() bool
- func (h *Hub) Del(clientId string)
- func (h *Hub) DelFromGroup(groupId string, wsChan *WsChannal)
- func (h *Hub) Get(clientId string) *WsChannal
- func (h *Hub) GetGroup(groupId string) []*WsChannal
- func (h *Hub) Len() int
- type Msg
- type WsChannal
- func (c *WsChannal) Close()
- func (wsc *WsChannal) Del(key string)
- func (wsc *WsChannal) Get(key string) (value any, exists bool)
- func (wsc *WsChannal) GetBool(key string) bool
- func (c *WsChannal) GetId() string
- func (wsc *WsChannal) GetInt(key string) int
- func (wsc *WsChannal) GetString(key string) string
- func (wsc *WsChannal) IsClosed() bool
- func (wsc *WsChannal) LocalAddr() net.Addr
- func (wsc *WsChannal) MustGet(key string) any
- func (wsc *WsChannal) RemoteAddr() net.Addr
- func (wsc *WsChannal) Set(key string, value interface{})
- func (c *WsChannal) SetId(id string)
- func (c *WsChannal) Write(msg *Msg) error
- type WsConfig
- type WsHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WsChannal ¶
type WsChannal struct { Conn *websocket.Conn //socket链接 Ctx map[string]any //上下文 Output chan *Msg //写队列 CloseChan chan byte // 关闭通知 WsHandler WsHandler //处理器 // contains filtered or unexported fields }
func NewWsChannl ¶
func (*WsChannal) RemoteAddr ¶
type WsHandler ¶
type WsHandler interface { ConnectGin(c *gin.Context) Connect(w http.ResponseWriter, r *http.Request) Heartbeat(wsc *WsChannal) error Send(deviceId string, data []byte) error SendToGroup(groupId string, data []byte) error Broadcast(data []byte) error MsgHandler(wsc *WsChannal, msg *Msg) Disconnect(wsc *WsChannal) error GetConfig() *WsConfig }
Click to show internal directories.
Click to hide internal directories.