Documentation ¶
Overview ¶
@Time : 2019-07-12 12:38 @Author : zr
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Center ¶
type Center struct {
// contains filtered or unexported fields
}
Center maintains the set of active Clients and broadcasts messages to the Clients.
func NewCenter ¶
func NewCenter(msgHandler func(ClientInterface, []byte)) *Center
func (*Center) AddClient ¶
func (c *Center) AddClient(client ClientInterface, w http.ResponseWriter, r *http.Request) error
serveWs handles websocket requests from the peer.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a middleman between the websocket connection and the center.
type ClientInterface ¶
type ClientInterface interface { GetId() uint64 Delete() // contains filtered or unexported methods }
type Clients ¶
type Clients map[uint64]ClientInterface
type MsgHandler ¶
type MsgHandler func(ClientInterface, []byte)
Click to show internal directories.
Click to hide internal directories.