Compare commits
5 commits
06633ff438
...
ffc994126b
Author | SHA1 | Date | |
---|---|---|---|
ffc994126b | |||
c20d36d2d2 | |||
0180aea8c1 | |||
16bc946a30 | |||
61b2f71bf3 |
8 changed files with 28 additions and 28 deletions
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -5,12 +5,12 @@ import (
|
|||
)
|
||||
|
||||
var Message = models.ServerMessage{
|
||||
Mode: "Idle",
|
||||
PomodoroSettings: DefaultPomodoroConfig,
|
||||
Session: 0,
|
||||
TimeLeft: DefaultPomodoroConfig.Work,
|
||||
Ongoing: false,
|
||||
Paused: false,
|
||||
Mode: "Idle",
|
||||
Settings: DefaultPomodoroConfig,
|
||||
Session: 0,
|
||||
TimeLeft: DefaultPomodoroConfig.Work,
|
||||
Ongoing: false,
|
||||
Paused: false,
|
||||
}
|
||||
|
||||
var PomodoroPassword string
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
|
||||
// ClientCommand represents a command from the client (start/stop).
|
||||
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
|
||||
Command string `json:"command"` // comman send to the server
|
||||
Password string `json:"password"` // pomodoro control password
|
||||
Settings PomodoroConfig `json:"settings"` // pomodoro config
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ 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
|
||||
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
|
||||
Mode string `json:"mode"` // "Idle", "Work", "ShortBreak", "LongBreak" or "End"
|
||||
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
|
||||
ProtocolVersion string `json:"version"` // Version of the server
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue