Compare commits
No commits in common. "ffc994126b1349930a20941357b3f97d2c0cfc2f" and "06633ff438e6608f1cd44072f1f5672e9321f44d" have entirely different histories.
ffc994126b
...
06633ff438
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.ProtocolVersion = strings.Split(metadata.GoTomatoVersion, ".")[0]
|
shared.Message.GoTomatoVersion = 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.ProtocolVersion)
|
fmt.Printf("Protocol-Version: %s\n", shared.Message.GoTomatoVersion)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
serverConfig := models.ServerConfig{
|
serverConfig := models.GoTomatoServerConfig{
|
||||||
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.Settings
|
pomodoroConfig := shared.Message.PomodoroSettings
|
||||||
|
|
||||||
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.Settings.Work
|
shared.Message.TimeLeft = shared.Message.PomodoroSettings.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.ServerConfig{
|
var DefaultServerConfig = models.GoTomatoServerConfig{
|
||||||
ListenAddress: "0.0.0.0",
|
ListenAddress: "0.0.0.0",
|
||||||
ListenPort: 8080,
|
ListenPort: 8080,
|
||||||
}
|
}
|
||||||
|
|
||||||
var DefaultPomodoroConfig = models.PomodoroConfig{
|
var DefaultPomodoroConfig = models.GoTomatoPomodoroConfig{
|
||||||
Work: 25 * 60,
|
Work: 25 * 60,
|
||||||
ShortBreak: 5 * 60,
|
ShortBreak: 5 * 60,
|
||||||
LongBreak: 15 * 60,
|
LongBreak: 15 * 60,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
var Message = models.ServerMessage{
|
var Message = models.ServerMessage{
|
||||||
Mode: "Idle",
|
Mode: "Idle",
|
||||||
Settings: DefaultPomodoroConfig,
|
PomodoroSettings: DefaultPomodoroConfig,
|
||||||
Session: 0,
|
Session: 0,
|
||||||
TimeLeft: DefaultPomodoroConfig.Work,
|
TimeLeft: DefaultPomodoroConfig.Work,
|
||||||
Ongoing: false,
|
Ongoing: false,
|
||||||
|
|
|
@ -49,9 +49,9 @@ func handleClientCommands(ws *websocket.Conn) {
|
||||||
}
|
}
|
||||||
case "updateSettings":
|
case "updateSettings":
|
||||||
if !pomodoro.IsPomodoroOngoing() {
|
if !pomodoro.IsPomodoroOngoing() {
|
||||||
if clientCommand.Settings != (models.PomodoroConfig{}) {
|
if clientCommand.PomodoroSettings != (models.GoTomatoPomodoroConfig{}) {
|
||||||
shared.Message.Settings = clientCommand.Settings
|
shared.Message.PomodoroSettings = clientCommand.PomodoroSettings
|
||||||
shared.Message.TimeLeft = clientCommand.Settings.Work
|
shared.Message.TimeLeft = clientCommand.PomodoroSettings.Work
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
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
|
||||||
Settings PomodoroConfig `json:"settings"` // pomodoro config
|
PomodoroSettings GoTomatoPomodoroConfig `json:"settings"` // pomodoro config
|
||||||
}
|
}
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
type PomodoroConfig struct {
|
type GoTomatoPomodoroConfig 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 ServerConfig struct {
|
type GoTomatoServerConfig 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
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@ 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"
|
||||||
Settings PomodoroConfig `json:"settings"` // The currrent pomodoro settings
|
PomodoroSettings GoTomatoPomodoroConfig `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
|
||||||
ProtocolVersion string `json:"version"` // Version of the server
|
GoTomatoVersion string `json:"version"` // Version of the server
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue