Sebastian Mark
6ffd9f1e38
- update import paths to reflect the new package name
- change function call to use the new websocket package
- adjust client iteration to use the renamed Clients variable
🤖
33 lines
870 B
Go
33 lines
870 B
Go
package server
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"git.smsvc.net/pomodoro/GoTomato/internal/websocket"
|
|
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func Start() {
|
|
// Define CLI flags for ListenAddress and ListenPort
|
|
listenAddress := flag.String("listenAddress", "0.0.0.0", "IP address to listen on")
|
|
listenPort := flag.Int("listenPort", 8080, "Port to listen on")
|
|
flag.Parse()
|
|
|
|
serverConfig := models.GoTomatoServerConfig{
|
|
ListenAddress: *listenAddress,
|
|
ListenPort: *listenPort,
|
|
}
|
|
|
|
listen := fmt.Sprintf("%s:%d", serverConfig.ListenAddress, serverConfig.ListenPort)
|
|
|
|
http.HandleFunc("/ws", websocket.HandleConnections)
|
|
go websocket.SendPermanentBroadCastMessage()
|
|
|
|
log.Printf("Pomodoro WebSocket server started on %s\n", listen)
|
|
err := http.ListenAndServe(listen, nil)
|
|
if err != nil {
|
|
log.Fatalf("Error starting server: %v", err)
|
|
}
|
|
}
|