Documentation
¶
Overview ¶
Package ws handles WebSocket connections and broadcasting messages to clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Client ID.
ID int
// Hub.
Hub *Hub
// WebSocket connection.
Conn *websocket.Conn
// To prevent pushes to the channel.
Closed SafeBool
// Buffered channel of outbound ws messages.
Send chan models.WSMessage
}
Client is a single connected WS user.
func (*Client) Listen ¶
func (c *Client) Listen()
Listen is a block method that listens for incoming messages from the client.
func (*Client) SendMessage ¶
SendMessage sends a message to client.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub maintains the set of registered websockets clients.
func (*Hub) BroadcastMessage ¶
func (h *Hub) BroadcastMessage(msg models.BroadcastMessage)
BroadcastMessage broadcasts a message to the specified users. If no users are specified, the message is broadcast to all users.
func (*Hub) RemoveClient ¶
RemoveClient removes a client from the hub.
Click to show internal directories.
Click to hide internal directories.