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.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/backend/game/hub.go b/backend/game/hub.go
index 0b12ce9..bb82170 100644
--- a/backend/game/hub.go
+++ b/backend/game/hub.go
@@ -34,6 +34,7 @@ type gameHub struct {
watchers map[*watcherClient]bool
registerWatcher chan *watcherClient
unregisterWatcher chan *watcherClient
+ testcaseExecution chan string
}
func newGameHub(ctx context.Context, game *game, q *db.Queries, taskQueue *taskqueue.Queue) *gameHub {
@@ -49,6 +50,7 @@ func newGameHub(ctx context.Context, game *game, q *db.Queries, taskQueue *taskq
watchers: make(map[*watcherClient]bool),
registerWatcher: make(chan *watcherClient),
unregisterWatcher: make(chan *watcherClient),
+ testcaseExecution: make(chan string),
}
}
@@ -185,6 +187,16 @@ func (hub *gameHub) run() {
default:
log.Printf("unexpected message type: %T", message.message)
}
+ case executionStatus := <-hub.testcaseExecution:
+ for player := range hub.players {
+ player.s2cMessages <- &playerMessageS2CExecResult{
+ Type: playerMessageTypeS2CExecResult,
+ Data: playerMessageS2CExecResultPayload{
+ Score: nil,
+ Status: api.GamePlayerMessageS2CExecResultPayloadStatus(executionStatus),
+ },
+ }
+ }
case <-ticker.C:
if hub.game.state == gameStateStarting {
if time.Now().After(*hub.game.startedAt) {
@@ -344,3 +356,7 @@ func (hubs *GameHubs) StartGame(gameID int) error {
}
return hub.startGame()
}
+
+func (hubs *GameHubs) C() chan string {
+ return hubs.hubs[4].testcaseExecution
+}