Documentation ¶
Index ¶
- Variables
- func SendAll(msg []byte)
- func SendGroup(msg []byte)
- func SendOne(ctx context.Context, id string, group string, msg []byte)
- func WsLogout(id string, group string)
- type BroadCastMessageData
- type Client
- type GroupMessageData
- type Manager
- func (manager *Manager) Info() map[string]interface{}
- func (manager *Manager) LenClient() uint
- func (manager *Manager) LenGroup() uint
- func (manager *Manager) RegisterClient(client *Client)
- func (manager *Manager) Send(cxt context.Context, id string, group string, message []byte)
- func (manager *Manager) SendAll(message []byte)
- func (manager *Manager) SendAllService()
- func (manager *Manager) SendGroup(group string, message []byte)
- func (manager *Manager) SendGroupService()
- func (manager *Manager) SendService()
- func (manager *Manager) Start()
- func (manager *Manager) UnRegisterClient(client *Client)
- func (manager *Manager) UnWsClient(c *gin.Context)
- func (manager *Manager) WsClient(c *gin.Context)
- type MessageData
Constants ¶
This section is empty.
Variables ¶
View Source
var WebsocketManager = Manager{ Group: make(map[string]map[string]*Client), Register: make(chan *Client, 128), UnRegister: make(chan *Client, 128), GroupMessage: make(chan *GroupMessageData, 128), Message: make(chan *MessageData, 128), BroadCastMessage: make(chan *BroadCastMessageData, 128), // contains filtered or unexported fields }
初始化 wsManager 管理器
Functions ¶
Types ¶
type Client ¶
type Client struct {
Id, Group string
Context context.Context
CancelFunc context.CancelFunc
Socket *websocket.Conn
Message chan []byte
}
Client 单个 websocket 信息
type GroupMessageData ¶
groupMessageData 组广播数据信息
type Manager ¶
type Manager struct { Group map[string]map[string]*Client Lock sync.Mutex Register, UnRegister chan *Client Message chan *MessageData GroupMessage chan *GroupMessageData BroadCastMessage chan *BroadCastMessageData // contains filtered or unexported fields }
Manager 所有 websocket 信息
func (*Manager) UnWsClient ¶
Click to show internal directories.
Click to hide internal directories.