feat: implement permanent broadcast message functionality
- add SendPermanentBroadCastMessage to continuously send updates
- refactor BroadcastMessage to use a shared Message struct
- update pomodoro logic to modify broadcast.Message directly
- adjust client command handling to use broadcast.Clients map
- enhance ServerMessage struct with "Ongoing" and "Paused" fields
🤖
This commit is contained in:
parent
eba4065c6f
commit
9615d4d449
8 changed files with 75 additions and 65 deletions
|
@ -2,6 +2,7 @@ package websocket
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/broadcast"
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/pomodoro"
|
||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
"github.com/gorilla/websocket"
|
||||
|
@ -24,7 +25,7 @@ func handleClientCommands(ws *websocket.Conn) {
|
|||
_, message, err := ws.ReadMessage()
|
||||
if err != nil {
|
||||
log.Printf("Client disconnected: %v", err)
|
||||
delete(Clients, ws)
|
||||
delete(broadcast.Clients, ws)
|
||||
break
|
||||
}
|
||||
|
||||
|
@ -42,11 +43,11 @@ func handleClientCommands(ws *websocket.Conn) {
|
|||
if clientCommand.Config != unsetPomodoroConfig {
|
||||
pomodoroConfig = clientCommand.Config
|
||||
}
|
||||
go pomodoro.RunPomodoro(Clients, pomodoroConfig) // Start the timer with the list of clients
|
||||
go pomodoro.RunPomodoro(broadcast.Clients, pomodoroConfig) // Start the timer with the list of clients
|
||||
}
|
||||
case "stop":
|
||||
if pomodoro.IsPomodoroOngoing() {
|
||||
pomodoro.ResetPomodoro(Clients) // Reset Pomodoro
|
||||
pomodoro.ResetPomodoro(broadcast.Clients) // Reset Pomodoro
|
||||
}
|
||||
case "pause":
|
||||
if pomodoro.IsPomodoroOngoing() && !pomodoro.IsPomodoroPaused() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue