Commit 280a85fa authored by nanahira's avatar nanahira

observer no kick

parent c4502f43
Pipeline #43391 passed with stages
in 3 minutes and 1 second
import { import {
NetPlayerType,
YGOProCtosBase, YGOProCtosBase,
YGOProCtosExternalAddress, YGOProCtosExternalAddress,
YGOProCtosJoinGame, YGOProCtosJoinGame,
...@@ -22,6 +23,7 @@ import { ...@@ -22,6 +23,7 @@ import {
} from 'rxjs'; } from 'rxjs';
import { YGOProCtosDisconnect } from '../utility/ygopro-ctos-disconnect'; import { YGOProCtosDisconnect } from '../utility/ygopro-ctos-disconnect';
import PQueue from 'p-queue'; import PQueue from 'p-queue';
import { DuelStage, RoomManager } from '../room';
export class ClientHandler { export class ClientHandler {
private static readonly CLIENT_IDLE_TIMEOUT_MS = 5 * 60 * 1000; private static readonly CLIENT_IDLE_TIMEOUT_MS = 5 * 60 * 1000;
...@@ -174,6 +176,16 @@ export class ClientHandler { ...@@ -174,6 +176,16 @@ export class ClientHandler {
filter((msg) => !this.isPreHandshakeMsg(msg)), filter((msg) => !this.isPreHandshakeMsg(msg)),
startWith(undefined), startWith(undefined),
switchMap(() => timer(ClientHandler.CLIENT_IDLE_TIMEOUT_MS)), switchMap(() => timer(ClientHandler.CLIENT_IDLE_TIMEOUT_MS)),
filter(() => {
const room = this.ctx
.get(() => RoomManager)
.findByName(client.roomName);
return !(
room &&
client.pos === NetPlayerType.OBSERVER &&
room.duelStage !== DuelStage.Begin
);
}),
take(1), take(1),
takeUntil(client.disconnect$), takeUntil(client.disconnect$),
) )
......
...@@ -25,6 +25,7 @@ export class RoomManager { ...@@ -25,6 +25,7 @@ export class RoomManager {
} }
findByName(name: string) { findByName(name: string) {
if (!name) return undefined;
return this.rooms.get(name); return this.rooms.get(name);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment