🆙 Renderer Logic Youtube Broadcast

This commit is contained in:
duckietm
2026-04-09 11:51:32 +02:00
parent 79d51246ec
commit 85d3422e86
16 changed files with 145 additions and 2 deletions
File diff suppressed because one or more lines are too long
@@ -490,4 +490,8 @@ export class IncomingHeader
public static USER_PREFIXES = 7001; public static USER_PREFIXES = 7001;
public static PREFIX_RECEIVED = 7002; public static PREFIX_RECEIVED = 7002;
public static ACTIVE_PREFIX_UPDATED = 7003; public static ACTIVE_PREFIX_UPDATED = 7003;
// YouTube Room Broadcast
public static YOUTUBE_ROOM_BROADCAST = 8001;
public static YOUTUBE_ROOM_WATCHERS = 8002;
} }
@@ -13,3 +13,4 @@ export * from './pet';
export * from './session'; export * from './session';
export * from './unit'; export * from './unit';
export * from './unit/chat'; export * from './unit/chat';
export * from './youtube';
@@ -0,0 +1,16 @@
import { IMessageEvent } from '@nitrots/api';
import { MessageEvent } from '@nitrots/events';
import { YouTubeRoomBroadcastParser } from '../../../parser';
export class YouTubeRoomBroadcastEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, YouTubeRoomBroadcastParser);
}
public getParser(): YouTubeRoomBroadcastParser
{
return this.parser as YouTubeRoomBroadcastParser;
}
}
@@ -0,0 +1,16 @@
import { IMessageEvent } from '@nitrots/api';
import { MessageEvent } from '@nitrots/events';
import { YouTubeRoomWatchersParser } from '../../../parser';
export class YouTubeRoomWatchersEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, YouTubeRoomWatchersParser);
}
public getParser(): YouTubeRoomWatchersParser
{
return this.parser as YouTubeRoomWatchersParser;
}
}
@@ -0,0 +1,2 @@
export * from './YouTubeRoomBroadcastEvent';
export * from './YouTubeRoomWatchersEvent';
@@ -503,4 +503,8 @@ export class OutgoingHeader
public static SET_ACTIVE_PREFIX = 7012; public static SET_ACTIVE_PREFIX = 7012;
public static DELETE_PREFIX = 7013; public static DELETE_PREFIX = 7013;
public static PURCHASE_PREFIX = 7014; public static PURCHASE_PREFIX = 7014;
// YouTube Room Broadcast
public static YOUTUBE_ROOM_PLAY = 8001;
public static YOUTUBE_ROOM_WATCHING = 8002;
} }
@@ -17,3 +17,4 @@ export * from './RedeemItemClothingComposer';
export * from './session'; export * from './session';
export * from './unit'; export * from './unit';
export * from './unit/chat'; export * from './unit/chat';
export * from './youtube';
@@ -0,0 +1,14 @@
import { IMessageComposer } from '@nitrots/api';
export class YouTubeRoomPlayComposer implements IMessageComposer<any[]>
{
private _data: any[];
constructor(videoId: string, playlist: string[])
{
this._data = [videoId, playlist.length, ...playlist];
}
public getMessageArray() { return this._data; }
public dispose(): void {}
}
@@ -0,0 +1,14 @@
import { IMessageComposer } from '@nitrots/api';
export class YouTubeRoomWatchingComposer implements IMessageComposer<any[]>
{
private _data: any[];
constructor(watching: boolean)
{
this._data = [watching];
}
public getMessageArray() { return this._data; }
public dispose(): void {}
}
@@ -0,0 +1,2 @@
export * from './YouTubeRoomPlayComposer';
export * from './YouTubeRoomWatchingComposer';
@@ -1,4 +1,4 @@
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api'; import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
export class BadgeReceivedParser implements IMessageParser export class BadgeReceivedParser implements IMessageParser
{ {
@@ -13,3 +13,4 @@ export * from './pet';
export * from './session'; export * from './session';
export * from './unit'; export * from './unit';
export * from './unit/chat'; export * from './unit/chat';
export * from './youtube';
@@ -0,0 +1,35 @@
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
export class YouTubeRoomBroadcastParser implements IMessageParser
{
private _videoId: string;
private _senderName: string;
private _playlist: string[];
public flush(): boolean
{
this._videoId = '';
this._senderName = '';
this._playlist = [];
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
this._videoId = wrapper.readString();
this._senderName = wrapper.readString();
const count = wrapper.readInt();
this._playlist = [];
for(let i = 0; i < count; i++)
{
this._playlist.push(wrapper.readString());
}
return true;
}
public get videoId(): string { return this._videoId; }
public get senderName(): string { return this._senderName; }
public get playlist(): string[] { return this._playlist; }
}
@@ -0,0 +1,27 @@
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
export class YouTubeRoomWatchersParser implements IMessageParser
{
private _watcherIds: number[];
public flush(): boolean
{
this._watcherIds = [];
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
const count = wrapper.readInt();
this._watcherIds = [];
for(let i = 0; i < count; i++)
{
this._watcherIds.push(wrapper.readInt());
}
return true;
}
public get watcherIds(): number[] { return this._watcherIds; }
}
@@ -0,0 +1,2 @@
export * from './YouTubeRoomBroadcastParser';
export * from './YouTubeRoomWatchersParser';