feat: add Password field to PomodoroClient
struct
remove unused password parameters from Client-Methods
🤖
This commit is contained in:
parent
0ca90b50a5
commit
b374ee8aff
4 changed files with 10 additions and 8 deletions
|
@ -36,6 +36,7 @@ func Start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
client := websocket.Connect(config.URL)
|
client := websocket.Connect(config.URL)
|
||||||
|
client.Password = config.Password
|
||||||
|
|
||||||
channel := make(chan GoTomato.ServerMessage)
|
channel := make(chan GoTomato.ServerMessage)
|
||||||
go websocket.ProcessServerMessages(client, channel)
|
go websocket.ProcessServerMessages(client, channel)
|
||||||
|
|
|
@ -24,12 +24,12 @@ func keyhandler(key keyboard.KeyEvent, client websocket.Client, config ChronoTom
|
||||||
switch key.Rune {
|
switch key.Rune {
|
||||||
case 0: // space
|
case 0: // space
|
||||||
cmd := start_pause_resume(message)
|
cmd := start_pause_resume(message)
|
||||||
client.SendCmd(config.Password, cmd)
|
client.SendCmd(cmd)
|
||||||
case 115: // s
|
case 115: // s
|
||||||
client.SendCmd(config.Password, "stop")
|
client.SendCmd("stop")
|
||||||
case 114: // r
|
case 114: // r
|
||||||
if config.PomodoroConfig != (GoTomato.PomodoroConfig{}) {
|
if config.PomodoroConfig != (GoTomato.PomodoroConfig{}) {
|
||||||
client.SendSettingsUpdate(config.Password, config.PomodoroConfig)
|
client.SendSettingsUpdate(config.PomodoroConfig)
|
||||||
}
|
}
|
||||||
case 113: // q
|
case 113: // q
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -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{
|
message := GoTomato.ClientCommand{
|
||||||
Command: cmd,
|
Command: cmd,
|
||||||
Password: pwd,
|
Password: c.Password,
|
||||||
}
|
}
|
||||||
|
|
||||||
c.sendClientCommand(message)
|
c.sendClientCommand(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Client) SendSettingsUpdate(pwd string, settings GoTomato.PomodoroConfig) {
|
func (c Client) SendSettingsUpdate(settings GoTomato.PomodoroConfig) {
|
||||||
message := GoTomato.ClientCommand{
|
message := GoTomato.ClientCommand{
|
||||||
Command: "updateSettings",
|
Command: "updateSettings",
|
||||||
Password: pwd,
|
Password: c.Password,
|
||||||
Settings: settings,
|
Settings: settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,5 +4,6 @@ import "github.com/gorilla/websocket"
|
||||||
|
|
||||||
// Represents a websocket client
|
// Represents a websocket client
|
||||||
type PomodoroClient struct {
|
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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue