Skip to content

Commit 52bc3a2

Browse files
committed
feat: Add games.*.started event
1 parent 926f8b8 commit 52bc3a2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

docs/WebSocket.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ However, the payload within the `data` field may contain any JSON value, not jus
6262
The following table shows which events may be sent.
6363
Some events are only visible to certain users for privacy reasons.
6464

65-
| Event Name | Payload | Visible to | Note |
66-
|----------------------------------------------------------------------------|----------------------------------------------------------------------------------|---------------------|-------------------------------------------------------|
65+
| Event Name | Payload | Visible to | Note |
66+
|----------------------------------------------------------------------------|----------------------------------------------------------------------------------|---------------------|--------------------------------------------------------|
6767
| `users.<userId>.{created,updated,deleted}`<sup>1, 2</sup> | [`User`](#model-User) | Everyone |
6868
| `users.<userId>.achievements.<id>.{created,updated,deleted}` | [`Achievement`](#model-Achievement) | Everyone |
6969
| `users.<from>.friends.<to>.{created,updated,deleted}` | [`Friend`](#model-Friend) | `from` or `to` User |
7070
| `games.<gameId>.{created,updated,deleted}` | [`Game`](#model-Game)<sup>4</sup> | Everyone |
71-
| `games.<gameId>.ticked` | [`Game`](#model-Game) | Everyone | Sent when ticking the game, after the `updated` event |
71+
| `games.<gameId>.started` | [`Game`](#model-Game) | Everyone | Sent when starting the game, after the `updated` event |
72+
| `games.<gameId>.ticked` | [`Game`](#model-Game) | Everyone | Sent when ticking the game, after the `updated` event |
7273
| `games.<gameId>.members.<userId>.{created,updated,deleted}` | [`Member`](#model-Member) | Everyone |
7374
| `games.<gameId>.systems.<systemId>.{created,updated,deleted}` | [`System`](#model-System) | Game Members |
7475
| `games.<gameId>.empires.<empireId>.{created,updated,deleted}` | [`Empire`](#model-Empire) or [`ReadEmpireDto`](#model-ReadEmpireDto)<sup>3</sup> | Game Members |

src/game/game.controller.ts

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export class GameController {
105105
const result = await this.gameService.update(id, dto, {populate: 'members'});
106106
if (result && !existing.started && result.started) {
107107
await this.gameLogicService.startGame(result);
108+
this.gameService.emit('started', result);
108109
}
109110
if (tick && result) {
110111
await this.gameLogicService.updateGame(result);

0 commit comments

Comments
 (0)