Admin: Pausieren und Fortsetzen des laufenden Matches
Neue Admin-Aktionen server/pause und server/resume senden mp_pause_match bzw. mp_unpause_match an den CS2-Server. Nur bei konfiguriertem Server verfügbar. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a6e7d7d287
commit
3e682d7fbc
4 files changed
+20
No files matched your search
@@ -92,6 +92,8 @@ export function createAdminRouter({ service, manager, config }) {
|
||||
action('server/stop', (v) => manager.stopByOrganizer(v));
|
||||
action('server/retry', (v) => manager.retry(v));
|
||||
action('server/warmup-end', (v) => manager.endWarmup(v));
|
||||
action('server/pause', (v) => manager.setPaused(v, true));
|
||||
action('server/resume', (v) => manager.setPaused(v, false));
|
||||
action('series/next', (v) => manager.loadNextMap(v));
|
||||
action('veto/start', (v) => service.startVeto(v));
|
||||
action('veto/action', (v, b) => service.vetoAction(
|
||||
|
||||
@@ -391,6 +391,21 @@ export class ServerManager {
|
||||
this.service.changed(viewer.matchId);
|
||||
}
|
||||
|
||||
/** Admin: pausiert oder setzt das laufende Match auf dem Server fort (mp_pause_match / mp_unpause_match). */
|
||||
async setPaused(viewer, paused) {
|
||||
this.service.require(viewer, 'organizer');
|
||||
const row = this.row(viewer.matchId);
|
||||
if (row?.status !== 'configured') throw new HttpError(409, 'Der Server ist nicht bereit', 'wrong_state');
|
||||
if (!this.adapter.sendCommands) throw new HttpError(501, 'Dieser Adapter unterstützt keine Befehle', 'unsupported');
|
||||
try {
|
||||
await this.adapter.sendCommands(JSON.parse(row.handle), [paused ? 'mp_pause_match' : 'mp_unpause_match']);
|
||||
} catch (err) {
|
||||
throw new HttpError(502, `Befehl konnte nicht gesendet werden: ${err.message}`, 'server_error');
|
||||
}
|
||||
this.service.log(viewer.matchId, 'server', paused ? 'Match pausiert (Admin)' : 'Match fortgesetzt (Admin)');
|
||||
this.service.changed(viewer.matchId);
|
||||
}
|
||||
|
||||
/** Demo-Modus: simuliert einen Matchverlauf, indem echte CS2-Logzeilen erzeugt und ausgewertet werden. */
|
||||
startDemoSimulation(matchId) {
|
||||
const match = this.service.getMatch(matchId);
|
||||
|
||||
@@ -401,6 +401,7 @@ test('Admin-Modus: Anmeldung, Verwaltung aller Matches, Sperre ohne Anmeldung',
|
||||
|
||||
// Ein Match abbrechen wie ein Admin
|
||||
assert.equal((await call('POST', `/admin/matches/${id}/cancel`, { ...admin, body: {} })).status, 200);
|
||||
assert.equal((await call('POST', `/admin/matches/${id}/server/pause`, { ...admin, body: {} })).status, 409, 'ohne Server keine Pause');
|
||||
assert.equal(app.service.getMatch(id).status, 'cancelled');
|
||||
|
||||
// Endgültig löschen
|
||||
|
||||
Reference in new issue
Block a user