Compare commits
2 commits
45c527cc79
...
d2e34e84f8
Author | SHA1 | Date | |
---|---|---|---|
d2e34e84f8 | |||
d0e1162726 |
3 changed files with 11 additions and 11 deletions
|
@ -6,13 +6,8 @@ import (
|
||||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Clients is a map of connected WebSocket clients, where each client is represented by the Client struct
|
|
||||||
var Clients = make(map[*websocket.Conn]*models.Client)
|
|
||||||
var mu sync.Mutex // Mutex to protect access to the Clients map
|
|
||||||
|
|
||||||
// handleClientCommands listens for commands from WebSocket clients and dispatches to the timer.
|
// handleClientCommands listens for commands from WebSocket clients and dispatches to the timer.
|
||||||
func handleClientCommands(ws *websocket.Conn) {
|
func handleClientCommands(ws *websocket.Conn) {
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -5,8 +5,13 @@ import (
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Clients is a map of connected WebSocket clients, where each client is represented by the Client struct
|
||||||
|
var Clients = make(map[*websocket.Conn]*models.Client)
|
||||||
|
var mu sync.Mutex // Mutex to protect access to the Clients map
|
||||||
|
|
||||||
// Upgrader to upgrade HTTP requests to WebSocket connections
|
// Upgrader to upgrade HTTP requests to WebSocket connections
|
||||||
var upgrader = websocket.Upgrader{
|
var upgrader = websocket.Upgrader{
|
||||||
CheckOrigin: func(r *http.Request) bool { return true },
|
CheckOrigin: func(r *http.Request) bool { return true },
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
type GoTomatoTimerConfig struct {
|
type GoTomatoTimerConfig struct {
|
||||||
Work int `json:"work"`
|
Work int `json:"work"` // Length of work sessions in seconds
|
||||||
ShortBreak int `json:"shortBreak"`
|
ShortBreak int `json:"shortBreak"` // Length of short break in seconds
|
||||||
LongBreak int `json:"longBreak"`
|
LongBreak int `json:"longBreak"` // Length if ling break in seconds
|
||||||
Sessions int `json:"sessions"`
|
Sessions int `json:"sessions"` // Number of total sessions
|
||||||
}
|
}
|
||||||
|
|
||||||
type GoTomatoServerConfig struct {
|
type GoTomatoServerConfig struct {
|
||||||
ListenAddress string `json:"listenAddress"`
|
ListenAddress string `json:"listenAddress"` // Server listen address
|
||||||
ListenPort int `json:"listenPort"`
|
ListenPort int `json:"listenPort"` // Server listen port
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue