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")
|
showVersionFlag := flag.Bool("version", false, "Output version")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
shared.Message.GoTomatoVersion = strings.Split(metadata.GoTomatoVersion, ".")[0]
|
shared.Message.ProtocolVersion = strings.Split(metadata.GoTomatoVersion, ".")[0]
|
||||||
if *showVersionFlag {
|
if *showVersionFlag {
|
||||||
fmt.Printf("App-Version: %s\n", metadata.GoTomatoVersion)
|
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)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig := models.GoTomatoServerConfig{
|
serverConfig := models.ServerConfig{
|
||||||
ListenAddress: *listenAddress,
|
ListenAddress: *listenAddress,
|
||||||
ListenPort: *listenPort,
|
ListenPort: *listenPort,
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ func RunPomodoro() {
|
||||||
shared.Message.Paused = false
|
shared.Message.Paused = false
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
|
|
||||||
pomodoroConfig := shared.Message.PomodoroSettings
|
pomodoroConfig := shared.Message.Settings
|
||||||
|
|
||||||
for session := 1; session <= pomodoroConfig.Sessions; session++ {
|
for session := 1; session <= pomodoroConfig.Sessions; session++ {
|
||||||
timer = timer.Init()
|
timer = timer.Init()
|
||||||
|
@ -66,7 +66,7 @@ func RunPomodoro() {
|
||||||
|
|
||||||
shared.Message.Mode = "Idle"
|
shared.Message.Mode = "Idle"
|
||||||
shared.Message.Session = 0
|
shared.Message.Session = 0
|
||||||
shared.Message.TimeLeft = shared.Message.PomodoroSettings.Work
|
shared.Message.TimeLeft = shared.Message.Settings.Work
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResetPomodoro() {
|
func ResetPomodoro() {
|
||||||
|
|
|
@ -4,12 +4,12 @@ import (
|
||||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
var DefaultServerConfig = models.GoTomatoServerConfig{
|
var DefaultServerConfig = models.ServerConfig{
|
||||||
ListenAddress: "0.0.0.0",
|
ListenAddress: "0.0.0.0",
|
||||||
ListenPort: 8080,
|
ListenPort: 8080,
|
||||||
}
|
}
|
||||||
|
|
||||||
var DefaultPomodoroConfig = models.GoTomatoPomodoroConfig{
|
var DefaultPomodoroConfig = models.PomodoroConfig{
|
||||||
Work: 25 * 60,
|
Work: 25 * 60,
|
||||||
ShortBreak: 5 * 60,
|
ShortBreak: 5 * 60,
|
||||||
LongBreak: 15 * 60,
|
LongBreak: 15 * 60,
|
||||||
|
|
|
@ -5,12 +5,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var Message = models.ServerMessage{
|
var Message = models.ServerMessage{
|
||||||
Mode: "Idle",
|
Mode: "Idle",
|
||||||
PomodoroSettings: DefaultPomodoroConfig,
|
Settings: DefaultPomodoroConfig,
|
||||||
Session: 0,
|
Session: 0,
|
||||||
TimeLeft: DefaultPomodoroConfig.Work,
|
TimeLeft: DefaultPomodoroConfig.Work,
|
||||||
Ongoing: false,
|
Ongoing: false,
|
||||||
Paused: false,
|
Paused: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
var PomodoroPassword string
|
var PomodoroPassword string
|
||||||
|
|
|
@ -49,9 +49,9 @@ func handleClientCommands(ws *websocket.Conn) {
|
||||||
}
|
}
|
||||||
case "updateSettings":
|
case "updateSettings":
|
||||||
if !pomodoro.IsPomodoroOngoing() {
|
if !pomodoro.IsPomodoroOngoing() {
|
||||||
if clientCommand.PomodoroSettings != (models.GoTomatoPomodoroConfig{}) {
|
if clientCommand.Settings != (models.PomodoroConfig{}) {
|
||||||
shared.Message.PomodoroSettings = clientCommand.PomodoroSettings
|
shared.Message.Settings = clientCommand.Settings
|
||||||
shared.Message.TimeLeft = clientCommand.PomodoroSettings.Work
|
shared.Message.TimeLeft = clientCommand.Settings.Work
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
|
|
||||||
// ClientCommand represents a command from the client (start/stop).
|
// ClientCommand represents a command from the client (start/stop).
|
||||||
type ClientCommand struct {
|
type ClientCommand struct {
|
||||||
Command string `json:"command"` // comman send to the server
|
Command string `json:"command"` // comman send to the server
|
||||||
Password string `json:"password"` // pomodoro control password
|
Password string `json:"password"` // pomodoro control password
|
||||||
PomodoroSettings GoTomatoPomodoroConfig `json:"settings"` // pomodoro config
|
Settings PomodoroConfig `json:"settings"` // pomodoro config
|
||||||
}
|
}
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
type GoTomatoPomodoroConfig struct {
|
type PomodoroConfig struct {
|
||||||
Work int `json:"work"` // Length of work sessions in seconds
|
Work int `json:"work"` // Length of work sessions in seconds
|
||||||
ShortBreak int `json:"shortBreak"` // Length of short break in seconds
|
ShortBreak int `json:"shortBreak"` // Length of short break in seconds
|
||||||
LongBreak int `json:"longBreak"` // Length if ling break in seconds
|
LongBreak int `json:"longBreak"` // Length if ling break in seconds
|
||||||
Sessions int `json:"sessions"` // Number of total sessions
|
Sessions int `json:"sessions"` // Number of total sessions
|
||||||
}
|
}
|
||||||
|
|
||||||
type GoTomatoServerConfig struct {
|
type ServerConfig struct {
|
||||||
ListenAddress string `json:"listenAddress"` // Server listen address
|
ListenAddress string `json:"listenAddress"` // Server listen address
|
||||||
ListenPort int `json:"listenPort"` // Server listen port
|
ListenPort int `json:"listenPort"` // Server listen port
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ package models
|
||||||
|
|
||||||
// ServerMessage represents the data sent to the client via WebSocket.
|
// ServerMessage represents the data sent to the client via WebSocket.
|
||||||
type ServerMessage struct {
|
type ServerMessage struct {
|
||||||
Mode string `json:"mode"` // "Idle", "Work", "ShortBreak", "LongBreak" or "End"
|
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
|
Session int `json:"session"` // Current session number
|
||||||
TimeLeft int `json:"time_left"` // Remaining time in seconds
|
TimeLeft int `json:"time_left"` // Remaining time in seconds
|
||||||
Ongoing bool `json:"ongoing"` // Ongoing pomodoro
|
Ongoing bool `json:"ongoing"` // Ongoing pomodoro
|
||||||
Paused bool `json:"paused"` // Is timer paused
|
Paused bool `json:"paused"` // Is timer paused
|
||||||
GoTomatoVersion string `json:"version"` // Version of the server
|
ProtocolVersion string `json:"version"` // Version of the server
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue