mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-22 23:50:52 +01:00
Co-authored-by: Bill <billsonnn@users.noreply.github.com>
This commit is contained in:
parent
f9cacc4d2b
commit
5c2580881d
File diff suppressed because one or more lines are too long
@ -401,6 +401,7 @@ export class IncomingHeader
|
||||
public static POLL_CONTENTS = 2997;
|
||||
public static POLL_ERROR = 662;
|
||||
public static POLL_OFFER = 3785;
|
||||
public static POLL_ROOM_RESULT = 5201;
|
||||
public static POLL_START_ROOM = 5200;
|
||||
public static QUESTION_ANSWERED = 2589;
|
||||
public static QUESTION_FINISHED = 1066;
|
||||
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../api';
|
||||
import { MessageEvent } from '../../../../../events';
|
||||
import { RoomPollResultParser } from '../../parser';
|
||||
|
||||
export class RoomPollResultEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, RoomPollResultParser);
|
||||
}
|
||||
|
||||
public getParser(): RoomPollResultParser
|
||||
{
|
||||
return this.parser as RoomPollResultParser;
|
||||
}
|
||||
}
|
@ -4,4 +4,5 @@ export * from './PollOfferEvent';
|
||||
export * from './QuestionAnsweredEvent';
|
||||
export * from './QuestionEvent';
|
||||
export * from './QuestionFinishedEvent';
|
||||
export * from './RoomPollResultEvent';
|
||||
export * from './StartRoomPollEvent';
|
||||
|
@ -0,0 +1,59 @@
|
||||
import { IMessageDataWrapper, IMessageParser } from '../../../../../api';
|
||||
|
||||
export class RoomPollResultParser implements IMessageParser
|
||||
{
|
||||
private _question: string;
|
||||
private _choices: string[];
|
||||
private _SafeStr_7651: any[];
|
||||
private _SafeStr_7654: number;
|
||||
|
||||
flush(): boolean
|
||||
{
|
||||
this._question = null;
|
||||
this._choices = [];
|
||||
this._SafeStr_7651 = [];
|
||||
this._SafeStr_7654 = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
this._question = wrapper.readString();
|
||||
|
||||
this._choices = [];
|
||||
this._SafeStr_7651 = [];
|
||||
|
||||
let totalChoices = wrapper.readInt();
|
||||
|
||||
while(totalChoices > 0)
|
||||
{
|
||||
this._choices.push(wrapper.readString());
|
||||
this._SafeStr_7651.push(wrapper.readInt());
|
||||
|
||||
totalChoices--;
|
||||
}
|
||||
this._SafeStr_7654 = wrapper.readInt();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get question(): string
|
||||
{
|
||||
return this._question;
|
||||
}
|
||||
|
||||
public get choices(): string[]
|
||||
{
|
||||
return this._choices;
|
||||
}
|
||||
|
||||
public get SafeStr_7651(): any[]
|
||||
{
|
||||
return this._SafeStr_7651;
|
||||
}
|
||||
|
||||
public get SafeStr_7654(): number
|
||||
{
|
||||
return this._SafeStr_7654;
|
||||
}
|
||||
}
|
@ -6,4 +6,5 @@ export * from './PollQuestion';
|
||||
export * from './QuestionAnsweredParser';
|
||||
export * from './QuestionFinishedParser';
|
||||
export * from './QuestionParser';
|
||||
export * from './RoomPollResultParser';
|
||||
export * from './RoomPollDataParser';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { IConnection, IRoomHandlerListener } from '../../../api';
|
||||
import { RoomSessionPollEvent, RoomSessionVoteEvent } from '../../../events';
|
||||
import { PollContentsEvent, PollErrorEvent, PollOfferEvent, StartRoomPollEvent } from '../../communication';
|
||||
import { PollContentsEvent, PollErrorEvent, PollOfferEvent, StartRoomPollEvent, RoomPollResultEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
export class PollHandler extends BaseHandler
|
||||
@ -13,6 +13,7 @@ export class PollHandler extends BaseHandler
|
||||
connection.addMessageEvent(new PollOfferEvent(this.onPollOfferEvent.bind(this)));
|
||||
connection.addMessageEvent(new PollErrorEvent(this.onPollErrorEvent.bind(this)));
|
||||
connection.addMessageEvent(new StartRoomPollEvent(this.onStartRoomPollEvent.bind(this)));
|
||||
connection.addMessageEvent(new RoomPollResultEvent(this.onRoomPollResultEvent.bind(this)));
|
||||
}
|
||||
|
||||
private onPollContentsEvent(event: PollContentsEvent): void
|
||||
@ -93,4 +94,21 @@ export class PollHandler extends BaseHandler
|
||||
|
||||
this.listener.events.dispatchEvent(pollEvent);
|
||||
}
|
||||
|
||||
private onRoomPollResultEvent(event: RoomPollResultEvent): void
|
||||
{
|
||||
if(!this.listener) return;
|
||||
|
||||
const session = this.listener.getSession(this.roomId);
|
||||
|
||||
if(!session) return;
|
||||
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
const pollEvent = new RoomSessionVoteEvent(RoomSessionVoteEvent.VOTE_RESULT, session, parser.question, parser.choices, parser.SafeStr_7651, parser.SafeStr_7654);
|
||||
|
||||
this.listener.events.dispatchEvent(pollEvent);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user