diff --git a/src/game/game.service.ts b/src/game/game.service.ts index 64ae6503f0745bf797bcf10aa5e641e509c502e1..5027c6e29d3b1a30824764e2f475d16d745de2c4 100644 --- a/src/game/game.service.ts +++ b/src/game/game.service.ts @@ -149,7 +149,9 @@ export class GameService { updatedGame.state = game.state; await this.gameRepository.save(updatedGame); // notify players about game state change - this.notificationGateway.server.emit(game.id, 'event update'); + this.notificationGateway.server.emit(game.id, { + type: 'gamestate-update', + }); return { code: 200, message: 'State was updated', @@ -217,7 +219,7 @@ export class GameService { }); await this.objectivePoint_HistoryRepository.insert(eventUpdate); // send flagbox event to flagbox subscribers - this.notificationGateway.server.emit('flagbox', 'event update'); + this.notificationGateway.server.emit(gameId, { type: 'flagbox-event' }); return { code: 201, message: 'OK', diff --git a/src/score/score.service.ts b/src/score/score.service.ts index 0ecea91032c73a6745e0ea0bd6dd207a510e31b0..9dad4e965ae797b31a2f708a7008048556db0992 100644 --- a/src/score/score.service.ts +++ b/src/score/score.service.ts @@ -10,7 +10,7 @@ import { GameEntity, } from '../game/game.entity'; import { ScoreEntity } from './score.entity'; -import { map } from 'rxjs/operators'; +import { NotificationGateway } from '../notifications/notifications.gateway'; @Injectable() export class ScoreService { @@ -23,6 +23,7 @@ export class ScoreService { private flagHistoryRepository: Repository<ObjectivePoint_HistoryEntity>, @InjectRepository(FactionEntity) private factionRepository: Repository<FactionEntity>, + private notificationGateway: NotificationGateway, ) {} async addScore(scoreData: ScoreDTO, gameId: GameEntity) { @@ -80,6 +81,7 @@ export class ScoreService { scoreData.map(async data => { await this.addScore(data, gameId); }); + this.notificationGateway.server.emit(gameId, { type: 'score-update' }); return { code: 200, message: 'Scores added', diff --git a/src/task/task.service.ts b/src/task/task.service.ts index cf4fe3ffa28f5226c8d8c8ccd8fea4b940bae672..eedef60368fa3db271f072dd402d675a1e84a234 100644 --- a/src/task/task.service.ts +++ b/src/task/task.service.ts @@ -36,8 +36,8 @@ export class TaskService { // notify subscribers about a new task // if faction was set it notifies only faction members, else everyone this.notificationGateway.server.emit( - task.faction != null ? task.faction.toString() : 'global', - 'new task', + task.faction != null ? task.faction.toString() : task.taskGame.toString(), + { type: 'task-update' }, ); return { code: 201,