Compare commits

..

5 commits

8 changed files with 28 additions and 28 deletions

View file

@ -21,14 +21,14 @@ func Start() {
showVersionFlag := flag.Bool("version", false, "Output version")
flag.Parse()
shared.Message.GoTomatoVersion = strings.Split(metadata.GoTomatoVersion, ".")[0]
shared.Message.ProtocolVersion = strings.Split(metadata.GoTomatoVersion, ".")[0]
if *showVersionFlag {
fmt.Printf("App-Version: %s\n", metadata.GoTomatoVersion)
fmt.Printf("Protocol-Version: %s\n", shared.Message.GoTomatoVersion)
fmt.Printf("Protocol-Version: %s\n", shared.Message.ProtocolVersion)
os.Exit(0)
}
serverConfig := models.GoTomatoServerConfig{
serverConfig := models.ServerConfig{
ListenAddress: *listenAddress,
ListenPort: *listenPort,
}

View file

@ -29,7 +29,7 @@ func RunPomodoro() {
shared.Message.Paused = false
mu.Unlock()
pomodoroConfig := shared.Message.PomodoroSettings
pomodoroConfig := shared.Message.Settings
for session := 1; session <= pomodoroConfig.Sessions; session++ {
timer = timer.Init()
@ -66,7 +66,7 @@ func RunPomodoro() {
shared.Message.Mode = "Idle"
shared.Message.Session = 0
shared.Message.TimeLeft = shared.Message.PomodoroSettings.Work
shared.Message.TimeLeft = shared.Message.Settings.Work
}
func ResetPomodoro() {

View file

@ -4,12 +4,12 @@ import (
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
)
var DefaultServerConfig = models.GoTomatoServerConfig{
var DefaultServerConfig = models.ServerConfig{
ListenAddress: "0.0.0.0",
ListenPort: 8080,
}
var DefaultPomodoroConfig = models.GoTomatoPomodoroConfig{
var DefaultPomodoroConfig = models.PomodoroConfig{
Work: 25 * 60,
ShortBreak: 5 * 60,
LongBreak: 15 * 60,

View file

@ -6,7 +6,7 @@ import (
var Message = models.ServerMessage{
Mode: "Idle",
PomodoroSettings: DefaultPomodoroConfig,
Settings: DefaultPomodoroConfig,
Session: 0,
TimeLeft: DefaultPomodoroConfig.Work,
Ongoing: false,

View file

@ -49,9 +49,9 @@ func handleClientCommands(ws *websocket.Conn) {
}
case "updateSettings":
if !pomodoro.IsPomodoroOngoing() {
if clientCommand.PomodoroSettings != (models.GoTomatoPomodoroConfig{}) {
shared.Message.PomodoroSettings = clientCommand.PomodoroSettings
shared.Message.TimeLeft = clientCommand.PomodoroSettings.Work
if clientCommand.Settings != (models.PomodoroConfig{}) {
shared.Message.Settings = clientCommand.Settings
shared.Message.TimeLeft = clientCommand.Settings.Work
}
}

View file

@ -10,7 +10,7 @@ import (
type ClientCommand struct {
Command string `json:"command"` // comman send to the server
Password string `json:"password"` // pomodoro control password
PomodoroSettings GoTomatoPomodoroConfig `json:"settings"` // pomodoro config
Settings PomodoroConfig `json:"settings"` // pomodoro config
}
type Client struct {

View file

@ -1,13 +1,13 @@
package models
type GoTomatoPomodoroConfig struct {
type PomodoroConfig struct {
Work int `json:"work"` // Length of work sessions in seconds
ShortBreak int `json:"shortBreak"` // Length of short break in seconds
LongBreak int `json:"longBreak"` // Length if ling break in seconds
Sessions int `json:"sessions"` // Number of total sessions
}
type GoTomatoServerConfig struct {
type ServerConfig struct {
ListenAddress string `json:"listenAddress"` // Server listen address
ListenPort int `json:"listenPort"` // Server listen port
}

View file

@ -3,10 +3,10 @@ package models
// ServerMessage represents the data sent to the client via WebSocket.
type ServerMessage struct {
Mode string `json:"mode"` // "Idle", "Work", "ShortBreak", "LongBreak" or "End"
PomodoroSettings GoTomatoPomodoroConfig `json:"settings"` // The currrent pomodoro settings
Settings PomodoroConfig `json:"settings"` // The currrent pomodoro settings
Session int `json:"session"` // Current session number
TimeLeft int `json:"time_left"` // Remaining time in seconds
Ongoing bool `json:"ongoing"` // Ongoing pomodoro
Paused bool `json:"paused"` // Is timer paused
GoTomatoVersion string `json:"version"` // Version of the server
ProtocolVersion string `json:"version"` // Version of the server
}