doc: add and improve comments

This commit is contained in:
Sebastian Mark 2024-10-30 07:37:14 +01:00
parent d83acc77b2
commit d0b1260f62
12 changed files with 50 additions and 26 deletions

View file

@ -6,19 +6,21 @@ import (
"sync"
)
// ClientCommand represents a command from the client (start/stop).
// Represents a command from the client (start/stop)
type ClientCommand struct {
Command string `json:"command"` // comman send to the server
Password string `json:"password"` // pomodoro control password
Settings PomodoroConfig `json:"settings"` // pomodoro config
Command string `json:"command"` // Command send to the server
Password string `json:"password"` // Pomodoro control password
Settings PomodoroConfig `json:"settings"` // Pomodoro config
}
// Represents a single client
type Client struct {
Conn *websocket.Conn
Mutex sync.Mutex
Conn *websocket.Conn // Websocket connection of the client
Mutex sync.Mutex // Mutex used to lock
}
// It automatically locks and unlocks the mutex to ensure that only one goroutine can write at a time.
// Sends a message to the websocket.
// Automatically locks and unlocks the client mutex, to ensure that only one goroutine can write at a time.
func (c *Client) SendMessage(messageType int, data []byte) error {
c.Mutex.Lock()
defer c.Mutex.Unlock()