aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/game/hub.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/game/hub.go')
-rw-r--r--backend/game/hub.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/backend/game/hub.go b/backend/game/hub.go
index 70bf71f..a44bce0 100644
--- a/backend/game/hub.go
+++ b/backend/game/hub.go
@@ -11,6 +11,7 @@ import (
"github.com/nsfisis/iosdc-japan-2024-albatross/backend/api"
"github.com/nsfisis/iosdc-japan-2024-albatross/backend/db"
+ "github.com/nsfisis/iosdc-japan-2024-albatross/backend/taskqueue"
)
type playerClientState int
@@ -25,6 +26,7 @@ type gameHub struct {
ctx context.Context
game *game
q *db.Queries
+ taskQueue *taskqueue.Queue
players map[*playerClient]playerClientState
registerPlayer chan *playerClient
unregisterPlayer chan *playerClient
@@ -34,11 +36,12 @@ type gameHub struct {
unregisterWatcher chan *watcherClient
}
-func newGameHub(ctx context.Context, game *game, q *db.Queries) *gameHub {
+func newGameHub(ctx context.Context, game *game, q *db.Queries, taskQueue *taskqueue.Queue) *gameHub {
return &gameHub{
ctx: ctx,
game: game,
q: q,
+ taskQueue: taskQueue,
players: make(map[*playerClient]playerClientState),
registerPlayer: make(chan *playerClient),
unregisterPlayer: make(chan *playerClient),
@@ -258,14 +261,16 @@ func (hub *gameHub) closeWatcherClient(watcher *watcherClient) {
}
type GameHubs struct {
- hubs map[int]*gameHub
- q *db.Queries
+ hubs map[int]*gameHub
+ q *db.Queries
+ taskQueue *taskqueue.Queue
}
-func NewGameHubs(q *db.Queries) *GameHubs {
+func NewGameHubs(q *db.Queries, taskQueue *taskqueue.Queue) *GameHubs {
return &GameHubs{
- hubs: make(map[int]*gameHub),
- q: q,
+ hubs: make(map[int]*gameHub),
+ q: q,
+ taskQueue: taskQueue,
}
}
@@ -313,7 +318,7 @@ func (hubs *GameHubs) RestoreFromDB(ctx context.Context) error {
startedAt: startedAt,
problem: problem_,
playerCount: len(playerRows),
- }, hubs.q)
+ }, hubs.q, hubs.taskQueue)
}
return nil
}