aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-05 02:36:50 +0900
committernsfisis <nsfisis@gmail.com>2024-08-05 03:02:18 +0900
commitdb6207a42296867d73ce5e960ee8542f84be3ebe (patch)
tree55db1c345c6e195017f370c0c399d5cc3d42b66e
parent968b835d0e6fe960c3d7ab915ef6d9cecec4ab7f (diff)
downloadiosdc-japan-2025-albatross-db6207a42296867d73ce5e960ee8542f84be3ebe.tar.gz
iosdc-japan-2025-albatross-db6207a42296867d73ce5e960ee8542f84be3ebe.tar.zst
iosdc-japan-2025-albatross-db6207a42296867d73ce5e960ee8542f84be3ebe.zip
feat(backend): disallow to connect to watch page in multiplayer mode
-rw-r--r--backend/game/http.go5
-rw-r--r--backend/game/models.go6
2 files changed, 10 insertions, 1 deletions
diff --git a/backend/game/http.go b/backend/game/http.go
index f9036c5..865c724 100644
--- a/backend/game/http.go
+++ b/backend/game/http.go
@@ -56,5 +56,10 @@ func (h *sockHandler) HandleSockGolfWatch(c echo.Context) error {
if hub == nil {
return echo.NewHTTPError(http.StatusNotFound, "Game not found")
}
+
+ if hub.game.gameType != gameType1v1 {
+ return echo.NewHTTPError(http.StatusBadRequest, "Only 1v1 game is supported")
+ }
+
return serveWatcherWs(hub, c.Response(), c.Request())
}
diff --git a/backend/game/models.go b/backend/game/models.go
index d3d0980..e96184a 100644
--- a/backend/game/models.go
+++ b/backend/game/models.go
@@ -6,9 +6,13 @@ import (
"github.com/nsfisis/iosdc-japan-2024-albatross/backend/api"
)
+type gameType = api.GameGameType
type gameState = api.GameState
const (
+ gameType1v1 = api.N1V1
+ gameTypeMultiplayer = api.Multiplayer
+
gameStateClosed gameState = api.Closed
gameStateWaitingEntries gameState = api.WaitingEntries
gameStateWaitingStart gameState = api.WaitingStart
@@ -20,7 +24,7 @@ const (
type game struct {
gameID int
- gameType string
+ gameType gameType
state gameState
displayName string
durationSeconds int