diff --git a/backend/src/events.ts b/backend/src/events.ts index 6685402..ac7fd52 100644 --- a/backend/src/events.ts +++ b/backend/src/events.ts @@ -15,6 +15,7 @@ import { MapStartEvent, MatchCreateEvent, MatchEndEvent, + MatchStopEvent, MatchUpdateEvent, RoundEndEvent, TMapMode, @@ -250,3 +251,8 @@ export const onMatchUpdate = (match: Match.Match, path: Array, const sendAsSysEvent = match.data.createdAt + 10000 > Date.now(); send(match, data, sendAsSysEvent); }; + +export const onMatchStop = (match: Match.Match) => { + const data: MatchStopEvent = getBaseEvent(match, 'MATCH_STOP'); + send(match, data); +}; diff --git a/backend/src/match.ts b/backend/src/match.ts index b805afe..b2c21fe 100644 --- a/backend/src/match.ts +++ b/backend/src/match.ts @@ -929,6 +929,7 @@ export const stop = async (match: Match) => { await say(match, `TMT IS OFFLINE`).catch(() => {}); await GameServer.disconnect(match); await ManagedGameServers.free(match.data.gameServer, match.data.id); + Events.onMatchStop(match); }; export const onElectionFinished = async (match: Match) => { diff --git a/backend/src/routes.ts b/backend/src/routes.ts index f4790d7..37d8694 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -708,6 +708,7 @@ const models: TsoaRoute.Models = { { dataType: 'enum', enums: ['LOG'] }, { dataType: 'enum', enums: ['MATCH_CREATE'] }, { dataType: 'enum', enums: ['MATCH_UPDATE'] }, + { dataType: 'enum', enums: ['MATCH_STOP'] }, ], validators: {}, }, @@ -1004,6 +1005,21 @@ const models: TsoaRoute.Models = { additionalProperties: false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + MatchStopEvent: { + dataType: 'refObject', + properties: { + timestamp: { dataType: 'string', required: true }, + matchId: { dataType: 'string', required: true }, + matchPassthrough: { + dataType: 'union', + subSchemas: [{ dataType: 'string' }, { dataType: 'enum', enums: [null] }], + required: true, + }, + type: { dataType: 'enum', enums: ['MATCH_STOP'], required: true }, + }, + additionalProperties: false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa Event: { dataType: 'refAlias', type: { @@ -1021,6 +1037,7 @@ const models: TsoaRoute.Models = { { ref: 'ElectionSideStep' }, { ref: 'MatchCreateEvent' }, { ref: 'MatchUpdateEvent' }, + { ref: 'MatchStopEvent' }, ], validators: {}, }, diff --git a/backend/src/settings.ts b/backend/src/settings.ts index 6dc008e..e6f6e9f 100644 --- a/backend/src/settings.ts +++ b/backend/src/settings.ts @@ -12,6 +12,7 @@ export const Settings = { 'MAP_END', 'MAP_START', 'MATCH_END', + 'MATCH_STOP', 'ROUND_END', - ] as EventType[], + ] satisfies EventType[] as EventType[], }; diff --git a/backend/swagger.json b/backend/swagger.json index edc64cc..e9db29a 100644 --- a/backend/swagger.json +++ b/backend/swagger.json @@ -1226,7 +1226,8 @@ "MATCH_END", "LOG", "MATCH_CREATE", - "MATCH_UPDATE" + "MATCH_UPDATE", + "MATCH_STOP" ] }, "ChatEvent": { @@ -1863,6 +1864,36 @@ "type": "object", "additionalProperties": false }, + "MatchStopEvent": { + "properties": { + "timestamp": { + "type": "string", + "description": "ISO" + }, + "matchId": { + "type": "string" + }, + "matchPassthrough": { + "type": "string", + "nullable": true + }, + "type": { + "type": "string", + "enum": [ + "MATCH_STOP" + ], + "nullable": false + } + }, + "required": [ + "timestamp", + "matchId", + "matchPassthrough", + "type" + ], + "type": "object", + "additionalProperties": false + }, "Event": { "anyOf": [ { @@ -1900,6 +1931,9 @@ }, { "$ref": "#/components/schemas/MatchUpdateEvent" + }, + { + "$ref": "#/components/schemas/MatchStopEvent" } ] }, diff --git a/common/types/events.ts b/common/types/events.ts index 16489f1..50666b2 100644 --- a/common/types/events.ts +++ b/common/types/events.ts @@ -18,7 +18,8 @@ export type EventType = | 'MATCH_END' | 'LOG' | 'MATCH_CREATE' - | 'MATCH_UPDATE'; + | 'MATCH_UPDATE' + | 'MATCH_STOP'; export interface BaseEvent { /** ISO */ @@ -136,6 +137,10 @@ export interface MatchUpdateEvent extends BaseEvent { value: any; } +export interface MatchStopEvent extends BaseEvent { + type: 'MATCH_STOP'; +} + export type Event = | ChatEvent | ElectionEndEvent @@ -148,4 +153,5 @@ export type Event = | ElectionMapStep | ElectionSideStep | MatchCreateEvent - | MatchUpdateEvent; + | MatchUpdateEvent + | MatchStopEvent;