Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChatHandler ¶
ChatHandler handles websocket requests from the peer.
Types ¶
type Client ¶
type Client struct { ClientID uint Name string Hub *Hub // Websockets connection Conn *ws.Conn // Buffered channel for the outgoing messages Send chan []byte SendJSON chan interface{} // Notification channel Notify chan interface{} }
Client stands between the hub and the ws connections
type ConnectedClient ¶
type ConnectedClient struct { gorm.Model UserID uint `gorm:"primaryKey"` Client *Client `gorm:"embedded"` LastSeen time.Time }
ConnectedClient holds the connection info of a specific client
type Hub ¶
type Hub struct { Connections map[uint]*ConnectedClient // Incoming messages from a client // to all connections subscribers of a channel Broadcast chan []byte // Incoming messages for a specific client Targeted chan *Message // returns connected users GetUsers chan *Client // Register client's requests Register chan *ConnectedClient // connects two peers Pair chan *db.PairedUsers // Unregister requests from the connections Unregister chan *ConnectedClient Notify chan Notification }
Hub maintains active connections and broadcast messages to connections
type Notification ¶
Click to show internal directories.
Click to hide internal directories.