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: soundboard packets
Add the soundboard message protocol mirroring the Arcturus side: - incoming SoundboardSettings (enabled flag + sound list) and SoundboardPlay (soundId, url, username) events + parsers - outgoing SoundboardPlay (soundId) and SoundboardSetEnabled composers - header ids 9405/9406 (incoming), 9306/9307 (outgoing) - NitroMessages registration + barrel exports
This commit is contained in:
@@ -11,6 +11,7 @@ import { HousekeepingActionLogEvent, HousekeepingActionResultEvent, Housekeeping
|
|||||||
import { RareValuesEvent, RequestRareValuesComposer } from './messages';
|
import { RareValuesEvent, RequestRareValuesComposer } from './messages';
|
||||||
import { WheelBuySpinComposer, WheelDataEvent, WheelOpenComposer, WheelRecentWinsEvent, WheelResultEvent, WheelSpinComposer } from './messages';
|
import { WheelBuySpinComposer, WheelDataEvent, WheelOpenComposer, WheelRecentWinsEvent, WheelResultEvent, WheelSpinComposer } from './messages';
|
||||||
import { WheelAdminGetPrizesComposer, WheelAdminPrizesEvent, WheelAdminSavePrizesComposer } from './messages';
|
import { WheelAdminGetPrizesComposer, WheelAdminPrizesEvent, WheelAdminSavePrizesComposer } from './messages';
|
||||||
|
import { SoundboardPlayEvent, SoundboardSettingsEvent, SoundboardPlayComposer, SoundboardSetEnabledComposer } from './messages';
|
||||||
export class NitroMessages implements IMessageConfiguration
|
export class NitroMessages implements IMessageConfiguration
|
||||||
{
|
{
|
||||||
private _events: Map<number, Function>;
|
private _events: Map<number, Function>;
|
||||||
@@ -524,6 +525,8 @@ export class NitroMessages implements IMessageConfiguration
|
|||||||
this._events.set(IncomingHeader.WHEEL_RESULT, WheelResultEvent);
|
this._events.set(IncomingHeader.WHEEL_RESULT, WheelResultEvent);
|
||||||
this._events.set(IncomingHeader.WHEEL_RECENT_WINS, WheelRecentWinsEvent);
|
this._events.set(IncomingHeader.WHEEL_RECENT_WINS, WheelRecentWinsEvent);
|
||||||
this._events.set(IncomingHeader.WHEEL_ADMIN_PRIZES, WheelAdminPrizesEvent);
|
this._events.set(IncomingHeader.WHEEL_ADMIN_PRIZES, WheelAdminPrizesEvent);
|
||||||
|
this._events.set(IncomingHeader.SOUNDBOARD_SETTINGS, SoundboardSettingsEvent);
|
||||||
|
this._events.set(IncomingHeader.SOUNDBOARD_PLAY, SoundboardPlayEvent);
|
||||||
this._events.set(IncomingHeader.WIRED_REWARD, WiredRewardResultMessageEvent);
|
this._events.set(IncomingHeader.WIRED_REWARD, WiredRewardResultMessageEvent);
|
||||||
this._events.set(IncomingHeader.WIRED_SAVE, WiredSaveSuccessEvent);
|
this._events.set(IncomingHeader.WIRED_SAVE, WiredSaveSuccessEvent);
|
||||||
this._events.set(IncomingHeader.WIRED_ERROR, WiredValidationErrorEvent);
|
this._events.set(IncomingHeader.WIRED_ERROR, WiredValidationErrorEvent);
|
||||||
@@ -1308,6 +1311,8 @@ export class NitroMessages implements IMessageConfiguration
|
|||||||
this._composers.set(OutgoingHeader.WHEEL_BUY_SPIN, WheelBuySpinComposer);
|
this._composers.set(OutgoingHeader.WHEEL_BUY_SPIN, WheelBuySpinComposer);
|
||||||
this._composers.set(OutgoingHeader.WHEEL_ADMIN_GET_PRIZES, WheelAdminGetPrizesComposer);
|
this._composers.set(OutgoingHeader.WHEEL_ADMIN_GET_PRIZES, WheelAdminGetPrizesComposer);
|
||||||
this._composers.set(OutgoingHeader.WHEEL_ADMIN_SAVE_PRIZES, WheelAdminSavePrizesComposer);
|
this._composers.set(OutgoingHeader.WHEEL_ADMIN_SAVE_PRIZES, WheelAdminSavePrizesComposer);
|
||||||
|
this._composers.set(OutgoingHeader.SOUNDBOARD_PLAY, SoundboardPlayComposer);
|
||||||
|
this._composers.set(OutgoingHeader.SOUNDBOARD_SET_ENABLED, SoundboardSetEnabledComposer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get events(): Map<number, Function>
|
public get events(): Map<number, Function>
|
||||||
|
|||||||
@@ -518,4 +518,6 @@ export class IncomingHeader
|
|||||||
public static WHEEL_RESULT = 9402;
|
public static WHEEL_RESULT = 9402;
|
||||||
public static WHEEL_RECENT_WINS = 9403;
|
public static WHEEL_RECENT_WINS = 9403;
|
||||||
public static WHEEL_ADMIN_PRIZES = 9404;
|
public static WHEEL_ADMIN_PRIZES = 9404;
|
||||||
|
public static SOUNDBOARD_SETTINGS = 9405;
|
||||||
|
public static SOUNDBOARD_PLAY = 9406;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export * from './handshake';
|
|||||||
export * from './help';
|
export * from './help';
|
||||||
export * from './housekeeping';
|
export * from './housekeeping';
|
||||||
export * from './rarevalues';
|
export * from './rarevalues';
|
||||||
|
export * from './soundboard';
|
||||||
export * from './wheel';
|
export * from './wheel';
|
||||||
export * from './inventory';
|
export * from './inventory';
|
||||||
export * from './inventory/achievements';
|
export * from './inventory/achievements';
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { IMessageEvent } from '@nitrots/api';
|
||||||
|
import { MessageEvent } from '@nitrots/events';
|
||||||
|
import { SoundboardPlayParser } from '../../parser';
|
||||||
|
|
||||||
|
export class SoundboardPlayEvent extends MessageEvent implements IMessageEvent
|
||||||
|
{
|
||||||
|
constructor(callBack: Function)
|
||||||
|
{
|
||||||
|
super(callBack, SoundboardPlayParser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getParser(): SoundboardPlayParser
|
||||||
|
{
|
||||||
|
return this.parser as SoundboardPlayParser;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { IMessageEvent } from '@nitrots/api';
|
||||||
|
import { MessageEvent } from '@nitrots/events';
|
||||||
|
import { SoundboardSettingsParser } from '../../parser';
|
||||||
|
|
||||||
|
export class SoundboardSettingsEvent extends MessageEvent implements IMessageEvent
|
||||||
|
{
|
||||||
|
constructor(callBack: Function)
|
||||||
|
{
|
||||||
|
super(callBack, SoundboardSettingsParser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getParser(): SoundboardSettingsParser
|
||||||
|
{
|
||||||
|
return this.parser as SoundboardSettingsParser;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './SoundboardPlayEvent';
|
||||||
|
export * from './SoundboardSettingsEvent';
|
||||||
@@ -556,4 +556,6 @@ export class OutgoingHeader
|
|||||||
public static WHEEL_BUY_SPIN = 9303;
|
public static WHEEL_BUY_SPIN = 9303;
|
||||||
public static WHEEL_ADMIN_GET_PRIZES = 9304;
|
public static WHEEL_ADMIN_GET_PRIZES = 9304;
|
||||||
public static WHEEL_ADMIN_SAVE_PRIZES = 9305;
|
public static WHEEL_ADMIN_SAVE_PRIZES = 9305;
|
||||||
|
public static SOUNDBOARD_PLAY = 9306;
|
||||||
|
public static SOUNDBOARD_SET_ENABLED = 9307;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export * from './handshake';
|
|||||||
export * from './help';
|
export * from './help';
|
||||||
export * from './housekeeping';
|
export * from './housekeeping';
|
||||||
export * from './rarevalues';
|
export * from './rarevalues';
|
||||||
|
export * from './soundboard';
|
||||||
export * from './wheel';
|
export * from './wheel';
|
||||||
export * from './inventory';
|
export * from './inventory';
|
||||||
export * from './inventory/avatareffect';
|
export * from './inventory/avatareffect';
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { IMessageComposer } from '@nitrots/api';
|
||||||
|
|
||||||
|
export class SoundboardPlayComposer implements IMessageComposer<[ number ]>
|
||||||
|
{
|
||||||
|
private _data: [ number ];
|
||||||
|
|
||||||
|
constructor(soundId: number)
|
||||||
|
{
|
||||||
|
this._data = [ soundId ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public getMessageArray(): [ number ] { return this._data; }
|
||||||
|
public dispose(): void { return; }
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import { IMessageComposer } from '@nitrots/api';
|
||||||
|
|
||||||
|
export class SoundboardSetEnabledComposer implements IMessageComposer<[ number ]>
|
||||||
|
{
|
||||||
|
private _data: [ number ];
|
||||||
|
|
||||||
|
constructor(enabled: boolean)
|
||||||
|
{
|
||||||
|
this._data = [ enabled ? 1 : 0 ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public getMessageArray(): [ number ] { return this._data; }
|
||||||
|
public dispose(): void { return; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './SoundboardPlayComposer';
|
||||||
|
export * from './SoundboardSetEnabledComposer';
|
||||||
@@ -26,6 +26,7 @@ export * from './handshake';
|
|||||||
export * from './help';
|
export * from './help';
|
||||||
export * from './housekeeping';
|
export * from './housekeeping';
|
||||||
export * from './rarevalues';
|
export * from './rarevalues';
|
||||||
|
export * from './soundboard';
|
||||||
export * from './wheel';
|
export * from './wheel';
|
||||||
export * from './inventory';
|
export * from './inventory';
|
||||||
export * from './inventory/achievements';
|
export * from './inventory/achievements';
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
|
||||||
|
|
||||||
|
export class SoundboardPlayParser implements IMessageParser
|
||||||
|
{
|
||||||
|
private _soundId: number = 0;
|
||||||
|
private _url: string = '';
|
||||||
|
private _username: string = '';
|
||||||
|
|
||||||
|
public flush(): boolean
|
||||||
|
{
|
||||||
|
this._soundId = 0;
|
||||||
|
this._url = '';
|
||||||
|
this._username = '';
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
|
{
|
||||||
|
if(!wrapper) return false;
|
||||||
|
|
||||||
|
this._soundId = wrapper.readInt();
|
||||||
|
this._url = wrapper.readString();
|
||||||
|
this._username = wrapper.readString();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get soundId(): number { return this._soundId; }
|
||||||
|
public get url(): string { return this._url; }
|
||||||
|
public get username(): string { return this._username; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
|
||||||
|
|
||||||
|
export interface ISoundboardSound
|
||||||
|
{
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SoundboardSettingsParser implements IMessageParser
|
||||||
|
{
|
||||||
|
private _enabled: boolean = false;
|
||||||
|
private _sounds: ISoundboardSound[] = [];
|
||||||
|
|
||||||
|
public flush(): boolean
|
||||||
|
{
|
||||||
|
this._enabled = false;
|
||||||
|
this._sounds = [];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
|
{
|
||||||
|
if(!wrapper) return false;
|
||||||
|
|
||||||
|
this._enabled = wrapper.readBoolean();
|
||||||
|
|
||||||
|
const count = wrapper.readInt();
|
||||||
|
this._sounds = [];
|
||||||
|
|
||||||
|
for(let i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
this._sounds.push({
|
||||||
|
id: wrapper.readInt(),
|
||||||
|
name: wrapper.readString(),
|
||||||
|
url: wrapper.readString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get enabled(): boolean { return this._enabled; }
|
||||||
|
public get sounds(): ISoundboardSound[] { return this._sounds; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './SoundboardPlayParser';
|
||||||
|
export * from './SoundboardSettingsParser';
|
||||||
Reference in New Issue
Block a user