package websocket import ( "encoding/json" "fmt" "git.smsvc.net/pomodoro/ChronoTomato/internal/notifications" "git.smsvc.net/pomodoro/ChronoTomato/internal/shared" "github.com/charmbracelet/log" "github.com/gorilla/websocket" ) var Done = make(chan struct{}) func ProcessServerMessages(conn *websocket.Conn) { defer close(Done) for { _, message, err := conn.ReadMessage() if err != nil { if websocket.IsCloseError(err, 1000) { // Ignore normal closure and exit gracefully return } // Log any other errors fmt.Println() log.Error("Read error!", "reason", err) return } err = json.Unmarshal(message, &shared.ServerMessage) if err != nil { log.Error("Error unmarshalling!", "reason", err) continue } notifications.DesktopNotifications() notifications.TerminalOutput() } }