Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Websocket = Hub{ Broadcast: make(chan []byte), Register: make(chan *Connection), Unregister: make(chan *Connection), Connections: make(map[*Connection]bool), }
Websocket global
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct { // WS connection. WS *websocket.Conn // Send buffered channel of outbound messages. Send chan []byte }
Connection is an middleman between the websocket connection and the hub.
func (*Connection) ReadPump ¶
func (c *Connection) ReadPump()
ReadPump pumps messages from the websocket hub.Connection to the hub.
func (*Connection) WritePump ¶
func (c *Connection) WritePump()
WritePump pumps messages from the hub to the websocket hub.Connection.
type Hub ¶
type Hub struct { // Connections registered connections. Connections map[*Connection]bool // Broadcast inbound messages from the connections. Broadcast chan []byte // Register requests from the connections. Register chan *Connection // Unregister requests from connections. Unregister chan *Connection }
Hub maintains the set of active connections and broadcasts messages to the connections.
Click to show internal directories.
Click to hide internal directories.