Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Managers = make(map[string]*ClientManager)
)
Managers - 用 name 来区分 manager, 不是很好复用连接 后期还是需要引入 Room 的概念
Functions ¶
func ServeWs ¶
func ServeWs(manager *ClientManager, w http.ResponseWriter, r *http.Request)
ServeWs 这里是要帮助 "客户端" 创建连接 & 实例化 Client & 注册该 Client
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 是存在于服务端对连接的抽象描述 & 每一个连接都需要初始化一个 Client Instance
type ClientManager ¶
type ClientManager struct { Broadcast chan []byte // contains filtered or unexported fields }
ClientManager stands for the hub of clients
func ManagerByName ¶
func ManagerByName(name string) *ClientManager
ManagerByName find manager by name
func (*ClientManager) Clients ¶
func (manager *ClientManager) Clients() map[*Client]bool
Clients returns all connected clients
Click to show internal directories.
Click to hide internal directories.