diff --git a/cmd/client/main.go b/cmd/client/main.go index 392ec5b..d2e920f 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -36,6 +36,7 @@ func Start() { } client := websocket.Connect(config.URL) + client.Password = config.Password channel := make(chan GoTomato.ServerMessage) go websocket.ProcessServerMessages(client, channel) diff --git a/internal/frontend/keyhandler.go b/internal/frontend/keyhandler.go index bd0805b..85a2e4c 100644 --- a/internal/frontend/keyhandler.go +++ b/internal/frontend/keyhandler.go @@ -24,12 +24,12 @@ func keyhandler(key keyboard.KeyEvent, client websocket.Client, config ChronoTom switch key.Rune { case 0: // space cmd := start_pause_resume(message) - client.SendCmd(config.Password, cmd) + client.SendCmd(cmd) case 115: // s - client.SendCmd(config.Password, "stop") + client.SendCmd("stop") case 114: // r if config.PomodoroConfig != (GoTomato.PomodoroConfig{}) { - client.SendSettingsUpdate(config.Password, config.PomodoroConfig) + client.SendSettingsUpdate(config.PomodoroConfig) } case 113: // q return false diff --git a/internal/websocket/send.go b/internal/websocket/send.go index fa736dd..650e24a 100644 --- a/internal/websocket/send.go +++ b/internal/websocket/send.go @@ -25,19 +25,19 @@ func (c Client) sendClientCommand(msg GoTomato.ClientCommand) { } } -func (c Client) SendCmd(pwd string, cmd string) { +func (c Client) SendCmd(cmd string) { message := GoTomato.ClientCommand{ Command: cmd, - Password: pwd, + Password: c.Password, } c.sendClientCommand(message) } -func (c Client) SendSettingsUpdate(pwd string, settings GoTomato.PomodoroConfig) { +func (c Client) SendSettingsUpdate(settings GoTomato.PomodoroConfig) { message := GoTomato.ClientCommand{ Command: "updateSettings", - Password: pwd, + Password: c.Password, Settings: settings, } diff --git a/pkg/models/client.go b/pkg/models/client.go index 3cd5007..cefc095 100644 --- a/pkg/models/client.go +++ b/pkg/models/client.go @@ -4,5 +4,6 @@ import "github.com/gorilla/websocket" // Represents a websocket client type PomodoroClient struct { - Conn *websocket.Conn // The websocket connection of the client + Conn *websocket.Conn // The websocket connection of the client + Password string // Pomodoro password }