Compare commits
No commits in common. "dd9490bb3b8e80b0b4b272ac67ecce896b8cdb9b" and "f4fd37c55165a80876f4d29bae2a82c83c42c1fd" have entirely different histories.
dd9490bb3b
...
f4fd37c551
3 changed files with 1 additions and 17 deletions
|
@ -2,5 +2,5 @@ package metadata
|
||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
const GoTomatoVersion = "v0.0.6" // The GoTomato version
|
const GoTomatoVersion = "v0.0.5" // The GoTomato version
|
||||||
var ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] // The protocol version
|
var ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] // The protocol version
|
||||||
|
|
|
@ -9,10 +9,6 @@ import (
|
||||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkSettings(settings models.PomodoroConfig) bool {
|
|
||||||
return settings.Work > 0 && settings.ShortBreak > 0 && settings.LongBreak > 0 && settings.Sessions > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Listens for commands from a client and handles them
|
// Listens for commands from a client and handles them
|
||||||
func handleClientCommands(c models.WebsocketClient) {
|
func handleClientCommands(c models.WebsocketClient) {
|
||||||
ws := c.Conn
|
ws := c.Conn
|
||||||
|
@ -54,11 +50,6 @@ func handleClientCommands(c models.WebsocketClient) {
|
||||||
}
|
}
|
||||||
case "updateSettings":
|
case "updateSettings":
|
||||||
if !pomodoro.IsPomodoroOngoing() {
|
if !pomodoro.IsPomodoroOngoing() {
|
||||||
if !checkSettings(clientCommand.Settings) {
|
|
||||||
log.Warn("Ignoring invalid config:", "msg", clientCommand.Settings, "host", c.Conn.RemoteAddr())
|
|
||||||
break
|
|
||||||
}
|
|
||||||
log.Info("Client send config", "config", clientCommand.Settings, "host", c.Conn.RemoteAddr())
|
|
||||||
pomodoro.UpdateSettings(clientCommand.Settings)
|
pomodoro.UpdateSettings(clientCommand.Settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// Represents the configuration of a pomodoro
|
// Represents the configuration of a pomodoro
|
||||||
type PomodoroConfig struct {
|
type PomodoroConfig struct {
|
||||||
Work int `json:"work"` // Length of work sessions in seconds
|
Work int `json:"work"` // Length of work sessions in seconds
|
||||||
|
@ -10,11 +8,6 @@ type PomodoroConfig struct {
|
||||||
Sessions int `json:"sessions"` // Number of total sessions
|
Sessions int `json:"sessions"` // Number of total sessions
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stringer interface for the PomodocoConfig model
|
|
||||||
func (c PomodoroConfig) String() string {
|
|
||||||
return fmt.Sprintf("{work: %d, short: %d, long: %d, sessions: %d}", c.Work, c.ShortBreak, c.LongBreak, c.Sessions)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Represents the server configuration
|
// Represents the server configuration
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
ListenAddress string `json:"listenAddress"` // Server listen address
|
ListenAddress string `json:"listenAddress"` // Server listen address
|
||||||
|
|
Loading…
Reference in a new issue