This section describes the WebSocket commands that clients can send to the Pomodoro server and the messages that the server sends to clients during a Pomodoro session.
### Message Format
Both client commands (sent to the server) and server messages (sent to the client) use the JSON format. The structure of these messages are described in the sections below.
Clients communicate with the server by sending JSON-encoded commands. Each command must include a `command` field specifying the action to perform and the control `password` required to manage the Pomodoro timer. The password is set by the server (see [Usage](#usage)).
If the client sends a command with an incorrect password it will not be allowed to control the Pomodoro, but will still receive server messages (see below). By default the password is an empty string which allows everyone to control the Pomodoro. In this case, the `password` field may be omitted in the client's command.
The Start-Command may contain an optional Pomodoro-Config, which allows you to customize the length of the work session, short break, long break, and the number of sessions. If no configuration is provided, the server will use default values.
The server periodically (every second) sends JSON-encoded messages to all connected clients to update them on the current state of the Pomodoro session. These messages contain the following fields:
- mode: Indicates the current phase of the Pomodoro session ("Work", "ShortBreak", "LongBreak", "End" or "Idle").
- settings: Contains the current Pomodoro settings:
- work: Length of the work session in seconds (e.g., 1500 for 25 minutes).
- shortBreak: Length of the short break in seconds (e.g., 300 for 5 minutes).
- longBreak: Length of the long break in seconds (e.g., 900 for 15 minutes).
- sessions: The total number of work/break sessions (e.g., 4).