mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-06-03 00:15:32 +02:00
53ab155f9c
* #28 - StartRoomPollEvent added * Added handler --------- Co-authored-by: Bill <billsonnn@users.noreply.github.com>
42 lines
841 B
TypeScript
42 lines
841 B
TypeScript
import { IMessageDataWrapper, IMessageParser } from '../../../../../api';
|
|
|
|
export class RoomPollDataParser implements IMessageParser
|
|
{
|
|
private _question: string;
|
|
private _choices: string[];
|
|
|
|
flush(): boolean
|
|
{
|
|
this._question = null;
|
|
this._choices = [];
|
|
return true;
|
|
}
|
|
|
|
parse(wrapper: IMessageDataWrapper): boolean
|
|
{
|
|
this._question = wrapper.readString();
|
|
this._choices = [];
|
|
|
|
const totalChoices = wrapper.readInt();
|
|
let total = 0;
|
|
|
|
while(total < totalChoices)
|
|
{
|
|
this._choices.push(wrapper.readString());
|
|
total++;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public get question(): string
|
|
{
|
|
return this._question;
|
|
}
|
|
|
|
public get choices(): string[]
|
|
{
|
|
return this._choices.slice();
|
|
}
|
|
}
|