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
feat(communication): housekeeping ban-user + generic action-result
* HousekeepingBanUserComposer (OutgoingHeader 9102): (userId, reason, hours). * HousekeepingActionResultEvent + Parser (IncomingHeader 9201): generic ack carrying (actionKey, ok, actionId, message). Same parser will back mute / kick / give-credits / room-close / etc. callers — adding a new HK action only needs a new outgoing composer plus the right ACTION_KEY constant on the server side. vitest 138/138, `yarn compile:fast` clean.
This commit is contained in:
@@ -7,7 +7,7 @@ import { ConfInvisStateMessageEvent } from './messages';
|
||||
import { HanditemBlockStateMessageEvent } from './messages';
|
||||
import { TranslationLanguagesEvent, TranslationLanguagesRequestComposer, TranslationResultEvent, TranslationTextRequestComposer } from './messages';
|
||||
import { YouTubeRoomBroadcastEvent, YouTubeRoomPlayComposer, YouTubeRoomSettingsComposer, YouTubeRoomSettingsEvent, YouTubeRoomWatchersEvent, YouTubeRoomWatchingComposer } from './messages';
|
||||
import { HousekeepingFindUserByIdComposer, HousekeepingFindUserByNameComposer, HousekeepingUserDetailEvent } from './messages';
|
||||
import { HousekeepingActionResultEvent, HousekeepingBanUserComposer, HousekeepingFindUserByIdComposer, HousekeepingFindUserByNameComposer, HousekeepingUserDetailEvent } from './messages';
|
||||
export class NitroMessages implements IMessageConfiguration
|
||||
{
|
||||
private _events: Map<number, Function>;
|
||||
@@ -509,6 +509,7 @@ export class NitroMessages implements IMessageConfiguration
|
||||
|
||||
// Housekeeping (in-client admin panel)
|
||||
this._events.set(IncomingHeader.HOUSEKEEPING_USER_DETAIL, HousekeepingUserDetailEvent);
|
||||
this._events.set(IncomingHeader.HOUSEKEEPING_ACTION_RESULT, HousekeepingActionResultEvent);
|
||||
this._events.set(IncomingHeader.WIRED_REWARD, WiredRewardResultMessageEvent);
|
||||
this._events.set(IncomingHeader.WIRED_SAVE, WiredSaveSuccessEvent);
|
||||
this._events.set(IncomingHeader.WIRED_ERROR, WiredValidationErrorEvent);
|
||||
@@ -1263,6 +1264,7 @@ export class NitroMessages implements IMessageConfiguration
|
||||
// Housekeeping (in-client admin panel)
|
||||
this._composers.set(OutgoingHeader.HOUSEKEEPING_FIND_USER_BY_NAME, HousekeepingFindUserByNameComposer);
|
||||
this._composers.set(OutgoingHeader.HOUSEKEEPING_FIND_USER_BY_ID, HousekeepingFindUserByIdComposer);
|
||||
this._composers.set(OutgoingHeader.HOUSEKEEPING_BAN_USER, HousekeepingBanUserComposer);
|
||||
}
|
||||
|
||||
public get events(): Map<number, Function>
|
||||
|
||||
@@ -506,4 +506,5 @@ export class IncomingHeader
|
||||
|
||||
// Housekeeping (in-client admin panel) — IDs 9200..9299 reserved
|
||||
public static HOUSEKEEPING_USER_DETAIL = 9200;
|
||||
public static HOUSEKEEPING_ACTION_RESULT = 9201;
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '@nitrots/api';
|
||||
import { MessageEvent } from '@nitrots/events';
|
||||
import { HousekeepingActionResultParser } from '../../parser';
|
||||
|
||||
export class HousekeepingActionResultEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, HousekeepingActionResultParser);
|
||||
}
|
||||
|
||||
public getParser(): HousekeepingActionResultParser
|
||||
{
|
||||
return this.parser as HousekeepingActionResultParser;
|
||||
}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export * from './HousekeepingActionResultEvent';
|
||||
export * from './HousekeepingUserDetailEvent';
|
||||
|
||||
@@ -526,4 +526,5 @@ export class OutgoingHeader
|
||||
// Housekeeping (in-client admin panel) — IDs 9100..9199 reserved
|
||||
public static HOUSEKEEPING_FIND_USER_BY_NAME = 9100;
|
||||
public static HOUSEKEEPING_FIND_USER_BY_ID = 9101;
|
||||
public static HOUSEKEEPING_BAN_USER = 9102;
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { IMessageComposer } from '@nitrots/api';
|
||||
|
||||
export class HousekeepingBanUserComposer implements IMessageComposer<ConstructorParameters<typeof HousekeepingBanUserComposer>>
|
||||
{
|
||||
private _data: ConstructorParameters<typeof HousekeepingBanUserComposer>;
|
||||
|
||||
constructor(userId: number, reason: string, hours: number)
|
||||
{
|
||||
this._data = [userId, reason, hours];
|
||||
}
|
||||
|
||||
public getMessageArray()
|
||||
{
|
||||
return this._data;
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './HousekeepingBanUserComposer';
|
||||
export * from './HousekeepingFindUserByIdComposer';
|
||||
export * from './HousekeepingFindUserByNameComposer';
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
|
||||
|
||||
/**
|
||||
* Generic ack for any housekeeping action (ban, mute, kick, give-credits,
|
||||
* room-close, …). Carries an `actionKey` string so a single event handler
|
||||
* can multiplex over many in-flight actions and resolve the right Promise
|
||||
* via an `accept` predicate.
|
||||
*/
|
||||
export class HousekeepingActionResultParser implements IMessageParser
|
||||
{
|
||||
private _actionKey: string = '';
|
||||
private _ok: boolean = false;
|
||||
private _actionId: number = 0;
|
||||
private _message: string = '';
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._actionKey = '';
|
||||
this._ok = false;
|
||||
this._actionId = 0;
|
||||
this._message = '';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
if(!wrapper) return false;
|
||||
|
||||
this._actionKey = wrapper.readString();
|
||||
this._ok = wrapper.readBoolean();
|
||||
this._actionId = wrapper.readInt();
|
||||
this._message = wrapper.readString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get actionKey(): string { return this._actionKey; }
|
||||
public get ok(): boolean { return this._ok; }
|
||||
public get actionId(): number { return this._actionId; }
|
||||
public get message(): string { return this._message; }
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './HousekeepingActionResultParser';
|
||||
export * from './HousekeepingUserDetailData';
|
||||
export * from './HousekeepingUserDetailParser';
|
||||
|
||||
Reference in New Issue
Block a user