You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 15:06:20 +00:00
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { GenericErrorEnum, IConnection, IRoomHandlerListener } from '@nitrots/api';
|
|
import { GenericErrorEvent } from '@nitrots/communication';
|
|
import { GetEventDispatcher, RoomSessionErrorMessageEvent } from '@nitrots/events';
|
|
import { BaseHandler } from './BaseHandler';
|
|
|
|
export class GenericErrorHandler extends BaseHandler
|
|
{
|
|
constructor(connection: IConnection, listener: IRoomHandlerListener)
|
|
{
|
|
super(connection, listener);
|
|
|
|
connection.addMessageEvent(new GenericErrorEvent(this.onRoomGenericError.bind(this)));
|
|
}
|
|
|
|
private onRoomGenericError(event: GenericErrorEvent): void
|
|
{
|
|
if(!(event instanceof GenericErrorEvent)) return;
|
|
|
|
const parser = event.getParser();
|
|
|
|
if(!parser) return;
|
|
|
|
const roomSession = this.listener.getSession(this.roomId);
|
|
|
|
if(!roomSession) return;
|
|
|
|
let type: string = '';
|
|
|
|
switch(parser.errorCode)
|
|
{
|
|
case GenericErrorEnum.KICKED_OUT_OF_ROOM:
|
|
type = RoomSessionErrorMessageEvent.RSEME_KICKED;
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
|
|
if(!type || type.length == 0) return;
|
|
|
|
GetEventDispatcher().dispatchEvent(new RoomSessionErrorMessageEvent(type, roomSession));
|
|
}
|
|
}
|