Compare commits

..

No commits in common. "ffc994126b1349930a20941357b3f97d2c0cfc2f" and "06633ff438e6608f1cd44072f1f5672e9321f44d" have entirely different histories.

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.ProtocolVersion = strings.Split(metadata.GoTomatoVersion, ".")[0]
shared.Message.GoTomatoVersion = strings.Split(metadata.GoTomatoVersion, ".")[0]
if *showVersionFlag {
fmt.Printf("App-Version: %s\n", metadata.GoTomatoVersion)
fmt.Printf("Protocol-Version: %s\n", shared.Message.ProtocolVersion)
fmt.Printf("Protocol-Version: %s\n", shared.Message.GoTomatoVersion)
os.Exit(0)
}
serverConfig := models.ServerConfig{
serverConfig := models.GoTomatoServerConfig{
ListenAddress: *listenAddress,
ListenPort: *listenPort,
}

View file

@ -29,7 +29,7 @@ func RunPomodoro() {
shared.Message.Paused = false
mu.Unlock()
pomodoroConfig := shared.Message.Settings
pomodoroConfig := shared.Message.PomodoroSettings
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.Settings.Work
shared.Message.TimeLeft = shared.Message.PomodoroSettings.Work
}
func ResetPomodoro() {

View file

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

View file

@ -6,7 +6,7 @@ import (
var Message = models.ServerMessage{
Mode: "Idle",
Settings: DefaultPomodoroConfig,
PomodoroSettings: 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.Settings != (models.PomodoroConfig{}) {
shared.Message.Settings = clientCommand.Settings
shared.Message.TimeLeft = clientCommand.Settings.Work
if clientCommand.PomodoroSettings != (models.GoTomatoPomodoroConfig{}) {
shared.Message.PomodoroSettings = clientCommand.PomodoroSettings
shared.Message.TimeLeft = clientCommand.PomodoroSettings.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
Settings PomodoroConfig `json:"settings"` // pomodoro config
PomodoroSettings GoTomatoPomodoroConfig `json:"settings"` // pomodoro config
}
type Client struct {

View file

@ -1,13 +1,13 @@
package models
type PomodoroConfig struct {
type GoTomatoPomodoroConfig 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 ServerConfig struct {
type GoTomatoServerConfig 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"
Settings PomodoroConfig `json:"settings"` // The currrent pomodoro settings
PomodoroSettings GoTomatoPomodoroConfig `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
ProtocolVersion string `json:"version"` // Version of the server
GoTomatoVersion string `json:"version"` // Version of the server
}