doc: add and improve comments
This commit is contained in:
parent
d83acc77b2
commit
d0b1260f62
12 changed files with 50 additions and 26 deletions
|
@ -9,7 +9,7 @@ import (
|
|||
"git.smsvc.net/pomodoro/GoTomato/internal/shared"
|
||||
)
|
||||
|
||||
// sends continous messages to all connected WebSocket clients.
|
||||
// Sends continous messages to all connected WebSocket clients
|
||||
func SendPermanentBroadCastMessage() {
|
||||
tick := time.NewTicker(time.Second)
|
||||
for {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
)
|
||||
|
||||
// handleClientCommands listens for commands from WebSocket clients
|
||||
// Listens for commands from a client and handles them
|
||||
func handleClientCommands(ws *websocket.Conn) {
|
||||
for {
|
||||
var clientCommand models.ClientCommand
|
||||
|
|
|
@ -13,12 +13,12 @@ import (
|
|||
var Clients = make(map[*websocket.Conn]*models.Client)
|
||||
var mu sync.Mutex // Mutex to protect access to the Clients map
|
||||
|
||||
// Upgrader to upgrade HTTP requests to WebSocket connections
|
||||
// Upgrade HTTP requests to WebSocket connections
|
||||
var upgrader = websocket.Upgrader{
|
||||
CheckOrigin: func(r *http.Request) bool { return true },
|
||||
}
|
||||
|
||||
// HandleConnection upgrades HTTP requests to WebSocket connections and manages the client lifecycle.
|
||||
// Upgrades HTTP requests to WebSocket connections and manages the client lifecycle
|
||||
func HandleConnection(w http.ResponseWriter, r *http.Request) {
|
||||
// Upgrade initial GET request to a WebSocket
|
||||
ws, err := upgrader.Upgrade(w, r, nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue