2024-10-19 10:05:10 +00:00
|
|
|
package server
|
2024-10-19 09:47:56 +00:00
|
|
|
|
|
|
|
import (
|
2024-10-20 12:31:52 +00:00
|
|
|
"fmt"
|
2024-10-19 09:47:56 +00:00
|
|
|
"git.smsvc.net/pomodoro/GoTomato/internal/websocket"
|
2024-10-20 12:31:52 +00:00
|
|
|
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
2024-10-19 09:47:56 +00:00
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2024-10-20 12:31:52 +00:00
|
|
|
var serverConfig = models.GoTomatoServerConfig{
|
|
|
|
ListenAddress: "0.0.0.0",
|
|
|
|
ListenPort: 8080,
|
|
|
|
}
|
|
|
|
|
2024-10-19 10:05:10 +00:00
|
|
|
func Start() {
|
2024-10-20 12:31:52 +00:00
|
|
|
listen := fmt.Sprintf("%s:%d", serverConfig.ListenAddress, serverConfig.ListenPort)
|
|
|
|
|
2024-10-19 09:47:56 +00:00
|
|
|
http.HandleFunc("/ws", websocket.HandleConnections)
|
|
|
|
|
2024-10-20 12:31:52 +00:00
|
|
|
log.Printf("Pomodoro WebSocket server started on %s\n", listen)
|
|
|
|
err := http.ListenAndServe(listen, nil)
|
2024-10-19 09:47:56 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Error starting server: %v", err)
|
|
|
|
}
|
|
|
|
}
|