Skip to content

Commit

Permalink
billsonnn#28 - PopularRoomTagsResultEvent added
Browse files Browse the repository at this point in the history
  • Loading branch information
oobjectt committed Dec 24, 2022
1 parent 26741b7 commit 029f7b0
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/nitro/communication/NitroMessages.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export class IncomingHeader
public static ROOM_SPECTATOR = 1033;
public static ROOM_THICKNESS = 3547;
public static ROOM_GET_FILTER_WORDS = 2937;
public static ROOM_POPULAR_TAGS_RESULT = 2012;
public static INFO_FEED_ENABLE = 3284;
public static SECURITY_MACHINE = 1488;
public static MYSTERY_BOX_KEYS = 2833;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { IMessageEvent } from '../../../../../api';
import { MessageEvent } from '../../../../../events';
import { PopularRoomTagsResultMessageParser } from '../../parser';

export class PopularRoomTagsResultEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, PopularRoomTagsResultMessageParser);
}

public getParser(): PopularRoomTagsResultMessageParser
{
return this.parser as PopularRoomTagsResultMessageParser;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export * from './NavigatorOpenRoomCreatorEvent';
export * from './NavigatorSearchesEvent';
export * from './NavigatorSearchEvent';
export * from './NavigatorSettingsEvent';
export * from './PopularRoomTagsResultEvent';
export * from './RoomEventCancelEvent';
export * from './RoomEventEvent';
export * from './RoomFilterSettingsMessageEvent';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { IMessageDataWrapper } from '../../../../../api';
import { PopularTagData } from './PopularTagData';

export class PopularRoomTagsData
{
private _tags: PopularTagData[];

constructor(wrapper: IMessageDataWrapper)
{
if(!wrapper) throw new Error('invalid_wrapper');

this.flush();
this.parse(wrapper);
}

public flush(): boolean
{
this._tags = [];

return true;
}

public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;

this._tags = [];

const totalTags = wrapper.readInt();

let total = 0;

while(total < totalTags)
{
this._tags.push(new PopularTagData(wrapper));
total++;
}

return true;
}

public get tags(): PopularTagData[]
{
return this._tags;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { IMessageDataWrapper, IMessageParser } from '../../../../../api';
import { PopularRoomTagsData } from './PopularRoomTagsData';

export class PopularRoomTagsResultMessageParser implements IMessageParser
{
private _data: PopularRoomTagsData;

public flush(): boolean
{
this._data = null;

return true;
}

public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;

this._data = new PopularRoomTagsData(wrapper);

return true;
}

public get data(): PopularRoomTagsData
{
return this._data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { IMessageDataWrapper } from '../../../../../api';

export class PopularTagData
{
private _tagName: string;
private _userCount: number;

constructor(wrapper: IMessageDataWrapper)
{
this._tagName = wrapper.readString();
this._userCount = wrapper.readInt();
}

public get tagName(): string
{
return this._tagName;
}

public get userCount(): number
{
return this._userCount;
}
}
3 changes: 3 additions & 0 deletions src/nitro/communication/messages/parser/navigator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export * from './NavigatorOpenRoomCreatorParser';
export * from './NavigatorSearchesParser';
export * from './NavigatorSearchParser';
export * from './NavigatorSettingsParser';
export * from './PopularRoomTagsData';
export * from './PopularRoomTagsResultMessageParser';
export * from './PopularTagData';
export * from './RoomEventCancelMessageParser';
export * from './RoomEventMessageParser';
export * from './RoomFilterSettingsMessageParser';
Expand Down

0 comments on commit 029f7b0

Please sign in to comment.