forked from billsonnn/nitro-renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
billsonnn#28 - PopularRoomTagsResultEvent added
- Loading branch information
Showing
8 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/nitro/communication/messages/incoming/navigator/PopularRoomTagsResultEvent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/nitro/communication/messages/parser/navigator/PopularRoomTagsData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/nitro/communication/messages/parser/navigator/PopularRoomTagsResultMessageParser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/nitro/communication/messages/parser/navigator/PopularTagData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters