fix(backend): handle leave message

This commit is contained in:
zyoshoka 2025-04-18 23:21:03 +09:00
parent dc55fba800
commit b71e299c8f
No known key found for this signature in database
2 changed files with 9 additions and 0 deletions

View File

@ -56,6 +56,7 @@ class MahjongRoomChannel extends Channel {
case 'ready': this.ready(body); break;
case 'updateSettings': this.updateSettings(body.key, body.value); break;
case 'addAi': this.addAi(); break;
case 'leave': this.leaveRoom(); break;
case 'confirmNextKyoku': this.confirmNextKyoku(); break;
case 'dahai': this.dahai(body.tile, body.riichi); break;
case 'tsumoHora': this.tsumoHora(); break;
@ -98,6 +99,13 @@ class MahjongRoomChannel extends Channel {
this.mahjongService.addAi(this.roomId!, this.user);
}
@bindThis
private async leaveRoom() {
if (this.user == null) return;
this.mahjongService.leaveRoom(this.roomId!, this.user);
}
@bindThis
private async dahai(tile: number, riichi = false) {
if (this.user == null) return;

View File

@ -358,6 +358,7 @@ export type Channels = {
body: unknown;
};
addAi: Record<string, never>;
leave: Record<string, never>;
confirmNextKyoku: Record<string, never>;
dahai: {
tile: number;