nitro-renderer/src/nitro/communication/messages/parser/poll/RoomPollDataParser.ts
object 53ab155f9c
#28 - StartRoomPollEvent added (#34)
* #28 - StartRoomPollEvent added

* Added handler

---------

Co-authored-by: Bill <billsonnn@users.noreply.github.com>
2023-04-29 19:38:35 -04:00

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();
}
}