Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a middleman between the websocket connection and the hub.
func NewClient ¶
func NewClient(dispatcher *Dispatcher, conn *websocket.Conn, channel string) *Client
NewClient creates and returns a pointer to a new client
func (*Client) Dispatcher ¶
func (c *Client) Dispatcher() *Dispatcher
Dispatcher returns the `Dispatcher` struct
func (*Client) ReadDispatch ¶
func (c *Client) ReadDispatch()
ReadDispatch pumps messages from the websocket connection to the dispatcher.
The application runs ReadDispatch in a per-connection goroutine. The application ensures that there is at most one reader on a connection by executing all reads from this goroutine.
func (*Client) WriteDispatch ¶
func (c *Client) WriteDispatch()
WriteDispatch pumps messages from the dispatcher to the websocket connection.
A goroutine running WriteDispatch is started for each connection. The application ensures that there is at most one writer to a connection by executing all writes from this goroutine.
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher maintains the set of active clients and broadcasts messages to the clients.
func (*Dispatcher) Broadcast ¶
func (d *Dispatcher) Broadcast() chan *Message
Broadcast returns the broadcast channel
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers handles websocket connections and provides an interface to dispatch events
func NewHandlers ¶
func NewHandlers(dispatcher *Dispatcher) *Handlers
NewHandlers creates and returns a pointer to a new instance of `Handler`
func (*Handlers) WebsocketHandler ¶
WebsocketHandler handles all of the websocket connections