Sebastian Mark
064056e8cb
- modify go.mod to reflect the new module path
- update config file path in the main function
- adjust import statements in various internal packages
- add install instructions to README
🤖
36 lines
700 B
Go
36 lines
700 B
Go
package websocket
|
|
|
|
import (
|
|
"git.smsvc.net/pomodoro/ChronoTomato/internal/notifications"
|
|
"git.smsvc.net/pomodoro/ChronoTomato/internal/shared"
|
|
"encoding/json"
|
|
"fmt"
|
|
"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 {
|
|
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()
|
|
}
|
|
|
|
}
|