mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-27 01:40:52 +01:00
added incoming poll packets
This commit is contained in:
parent
0d1922e958
commit
7ad0b94ed7
File diff suppressed because one or more lines are too long
@ -331,4 +331,10 @@ export class IncomingHeader
|
||||
public static YOUTUBE_DISPLAY_PLAYLISTS = 1112;
|
||||
public static YOUTUBE_DISPLAY_VIDEO = 1411;
|
||||
public static CFH_DISABLED_NOTIFY = 1651;
|
||||
public static QUESTION = 2665;
|
||||
public static POLL_CONTENTS = 2997;
|
||||
public static POLL_ERROR = 662;
|
||||
public static POLL_OFFER = 3785;
|
||||
public static QUESTION_ANSWERED = 2589;
|
||||
public static QUESTION_FINISHED = 1066;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ export * from './moderation';
|
||||
export * from './mysterybox';
|
||||
export * from './navigator';
|
||||
export * from './notifications';
|
||||
export * from './poll';
|
||||
export * from './quest';
|
||||
export * from './room';
|
||||
export * from './room/access';
|
||||
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
|
||||
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
|
||||
import { PollContentsParser } from '../../parser/poll/PollContentsParser';
|
||||
|
||||
export class PollContentsEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, PollContentsParser);
|
||||
}
|
||||
|
||||
public getParser(): PollContentsParser
|
||||
{
|
||||
return this.parser as PollContentsParser;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
|
||||
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
|
||||
import { PollErrorParser } from '../../parser/poll/PollErrorParser';
|
||||
|
||||
export class PollErrorEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, PollErrorParser);
|
||||
}
|
||||
|
||||
public getParser(): PollErrorParser
|
||||
{
|
||||
return this.parser as PollErrorParser;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
|
||||
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
|
||||
import { PollOfferParser } from '../../parser/poll/PollOfferParser';
|
||||
|
||||
export class PollOfferEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, PollOfferParser);
|
||||
}
|
||||
|
||||
public getParser(): PollOfferParser
|
||||
{
|
||||
return this.parser as PollOfferParser;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
|
||||
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
|
||||
import { QuestionAnsweredParser } from '../../parser/poll/QuestionAnsweredParser';
|
||||
|
||||
export class QuestionAnsweredEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, QuestionAnsweredParser);
|
||||
}
|
||||
|
||||
public getParser(): QuestionAnsweredParser
|
||||
{
|
||||
return this.parser as QuestionAnsweredParser;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
|
||||
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
|
||||
import { QuestionParser } from '../../parser/poll/QuestionParser';
|
||||
|
||||
export class QuestionEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, QuestionParser);
|
||||
}
|
||||
|
||||
public getParser(): QuestionParser
|
||||
{
|
||||
return this.parser as QuestionParser;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
|
||||
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
|
||||
import { QuestionFinishedParser } from '../../parser/poll/QuestionFinishedParser';
|
||||
|
||||
export class QuestionFinishedEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, QuestionFinishedParser);
|
||||
}
|
||||
|
||||
public getParser(): QuestionFinishedParser
|
||||
{
|
||||
return this.parser as QuestionFinishedParser;
|
||||
}
|
||||
}
|
6
src/nitro/communication/messages/incoming/poll/index.ts
Normal file
6
src/nitro/communication/messages/incoming/poll/index.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export * from './PollContentsEvent';
|
||||
export * from './PollErrorEvent';
|
||||
export * from './PollOfferEvent';
|
||||
export * from './QuestionAnsweredEvent';
|
||||
export * from './QuestionEvent';
|
||||
export * from './QuestionFinishedEvent';
|
@ -20,6 +20,7 @@ export * from './moderation';
|
||||
export * from './mysterybox';
|
||||
export * from './navigator';
|
||||
export * from './notifications';
|
||||
export * from './poll';
|
||||
export * from './quest';
|
||||
export * from './room';
|
||||
export * from './roomevents';
|
||||
|
43
src/nitro/communication/messages/parser/poll/PollChoice.ts
Normal file
43
src/nitro/communication/messages/parser/poll/PollChoice.ts
Normal file
@ -0,0 +1,43 @@
|
||||
export class PollChoice
|
||||
{
|
||||
private _value:string;
|
||||
private _choiceText:string;
|
||||
private _choiceType:number;
|
||||
|
||||
constructor(k:string, _arg_2:string, _arg_3:number)
|
||||
{
|
||||
this._value = k;
|
||||
this._choiceText = _arg_2;
|
||||
this._choiceType = _arg_3;
|
||||
}
|
||||
|
||||
public get value():string
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
public set value(value:string)
|
||||
{
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
public get choiceText():string
|
||||
{
|
||||
return this._choiceText;
|
||||
}
|
||||
|
||||
public set choiceText(choiceText:string)
|
||||
{
|
||||
this._choiceText = choiceText;
|
||||
}
|
||||
|
||||
public get choiceType():number
|
||||
{
|
||||
return this._choiceType;
|
||||
}
|
||||
|
||||
public set choiceType(k:number)
|
||||
{
|
||||
this._choiceType = k;
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper';
|
||||
import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser';
|
||||
import { PollChoice } from './PollChoice';
|
||||
import { PollQuestion } from './PollQuestion';
|
||||
|
||||
export class PollContentsParser implements IMessageParser
|
||||
{
|
||||
private _id = -1;
|
||||
private _startMessage = '';
|
||||
private _endMessage = '';
|
||||
private _numQuestions = 0;
|
||||
private _questionArray:PollQuestion[] = [];
|
||||
private _npsPoll = false
|
||||
|
||||
flush(): boolean
|
||||
{
|
||||
this._id = -1;
|
||||
this._startMessage = '';
|
||||
this._endMessage = '';
|
||||
this._numQuestions = 0;
|
||||
this._questionArray = [];
|
||||
return true;
|
||||
}
|
||||
|
||||
parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
this._id = wrapper.readInt();
|
||||
this._startMessage = wrapper.readString();
|
||||
this._endMessage = wrapper.readString();
|
||||
this._numQuestions = wrapper.readInt();
|
||||
|
||||
for(let i = 0; i < this._numQuestions; i++)
|
||||
{
|
||||
const question = this.parsePollQuestion(wrapper);
|
||||
const childrenCount = wrapper.readInt();
|
||||
|
||||
for(let j = 0; j < childrenCount; j++)
|
||||
{
|
||||
question.children.push(this.parsePollQuestion(wrapper));
|
||||
}
|
||||
|
||||
this._questionArray.push(question);
|
||||
}
|
||||
|
||||
this._npsPoll = wrapper.readBoolean();
|
||||
return true;
|
||||
}
|
||||
|
||||
private parsePollQuestion(k:IMessageDataWrapper):PollQuestion
|
||||
{
|
||||
const pollQuestion = new PollQuestion();
|
||||
pollQuestion.questionId = k.readInt();
|
||||
pollQuestion.sortOrder = k.readInt();
|
||||
pollQuestion.questionType = k.readInt();
|
||||
pollQuestion.questionText = k.readString();
|
||||
pollQuestion.questionCategory = k.readInt();
|
||||
pollQuestion.questionAnswerType = k.readInt();
|
||||
pollQuestion.questionAnswerCount = k.readInt();
|
||||
if(((pollQuestion.questionType == 1) || (pollQuestion.questionType == 2)))
|
||||
{
|
||||
for(let i = 0; i < pollQuestion.questionAnswerCount; i++)
|
||||
{
|
||||
pollQuestion.questionChoices.push(new PollChoice(k.readString(), k.readString(), k.readInt()));
|
||||
}
|
||||
}
|
||||
return pollQuestion;
|
||||
}
|
||||
|
||||
public get id():number
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public get startMessage():string
|
||||
{
|
||||
return this._startMessage;
|
||||
}
|
||||
|
||||
public get endMessage():string
|
||||
{
|
||||
return this._endMessage;
|
||||
}
|
||||
|
||||
public get numQuestions():number
|
||||
{
|
||||
return this._numQuestions;
|
||||
}
|
||||
|
||||
public get questionArray():PollQuestion[]
|
||||
{
|
||||
return this._questionArray;
|
||||
}
|
||||
|
||||
public get npsPoll():boolean
|
||||
{
|
||||
return this._npsPoll;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper';
|
||||
import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser';
|
||||
|
||||
export class PollErrorParser implements IMessageParser
|
||||
{
|
||||
flush(): boolean
|
||||
{
|
||||
throw true;
|
||||
}
|
||||
|
||||
parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper';
|
||||
import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser';
|
||||
|
||||
export class PollOfferParser implements IMessageParser
|
||||
{
|
||||
private _id = -1;
|
||||
private _type = '';
|
||||
private _headline = '';
|
||||
private _summary = '';
|
||||
|
||||
flush(): boolean
|
||||
{
|
||||
this._id = -1;
|
||||
this._type = '';
|
||||
this._summary = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
this._id = wrapper.readInt();
|
||||
this._type = wrapper.readString();
|
||||
this._headline = wrapper.readString();
|
||||
this._summary = wrapper.readString();
|
||||
return true;
|
||||
}
|
||||
|
||||
public get id():number
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public get type():string
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public get headline():string
|
||||
{
|
||||
return this._headline;
|
||||
}
|
||||
|
||||
public get summary():string
|
||||
{
|
||||
return this._summary;
|
||||
}
|
||||
}
|
110
src/nitro/communication/messages/parser/poll/PollQuestion.ts
Normal file
110
src/nitro/communication/messages/parser/poll/PollQuestion.ts
Normal file
@ -0,0 +1,110 @@
|
||||
import { PollChoice } from './PollChoice';
|
||||
|
||||
export class PollQuestion
|
||||
{
|
||||
private _questionId:number;
|
||||
private _questionType:number;
|
||||
private _sortOrder:number;
|
||||
private _questionCategory:number;
|
||||
private _questionText:string;
|
||||
private _questionAnswerType:number;
|
||||
private _questionAnswerCount:number;
|
||||
private _children:PollQuestion[];
|
||||
private _questionChoices:PollChoice[];
|
||||
|
||||
constructor()
|
||||
{
|
||||
this._children = [];
|
||||
this._questionChoices = [];
|
||||
}
|
||||
|
||||
public get questionId():number
|
||||
{
|
||||
return this._questionId;
|
||||
}
|
||||
|
||||
public set questionId(k:number)
|
||||
{
|
||||
this._questionId = k;
|
||||
}
|
||||
|
||||
public get questionType():number
|
||||
{
|
||||
return this._questionType;
|
||||
}
|
||||
|
||||
public set questionType(k:number)
|
||||
{
|
||||
this._questionType = k;
|
||||
}
|
||||
|
||||
public get sortOrder():number
|
||||
{
|
||||
return this._sortOrder;
|
||||
}
|
||||
|
||||
public set sortOrder(sortOrder:number)
|
||||
{
|
||||
this._sortOrder = sortOrder;
|
||||
}
|
||||
|
||||
public get questionText():string
|
||||
{
|
||||
return this._questionText;
|
||||
}
|
||||
|
||||
public set questionText(k:string)
|
||||
{
|
||||
this._questionText = k;
|
||||
}
|
||||
|
||||
public get questionCategory():number
|
||||
{
|
||||
return this._questionCategory;
|
||||
}
|
||||
|
||||
public set questionCategory(k:number)
|
||||
{
|
||||
this._questionCategory = k;
|
||||
}
|
||||
|
||||
public get questionAnswerType():number
|
||||
{
|
||||
return this._questionAnswerType;
|
||||
}
|
||||
|
||||
public set questionAnswerType(k:number)
|
||||
{
|
||||
this._questionAnswerType = k;
|
||||
}
|
||||
|
||||
public get questionAnswerCount():number
|
||||
{
|
||||
return this._questionAnswerCount;
|
||||
}
|
||||
|
||||
public set questionAnswerCount(k:number)
|
||||
{
|
||||
this._questionAnswerCount = k;
|
||||
}
|
||||
|
||||
public get children():PollQuestion[]
|
||||
{
|
||||
return this._children;
|
||||
}
|
||||
|
||||
public set children(children:PollQuestion[])
|
||||
{
|
||||
this._children = children;
|
||||
}
|
||||
|
||||
public get questionChoices():PollChoice[]
|
||||
{
|
||||
return this._questionChoices;
|
||||
}
|
||||
|
||||
public set questionChoices(k:PollChoice[])
|
||||
{
|
||||
this._questionChoices = k;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper';
|
||||
import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser';
|
||||
|
||||
export class QuestionAnsweredParser implements IMessageParser
|
||||
{
|
||||
private _userId:number;
|
||||
private _value:string;
|
||||
private _answerCounts:Map<string, number>;
|
||||
|
||||
flush(): boolean
|
||||
{
|
||||
this._userId = -1;
|
||||
this._value = '';
|
||||
this._answerCounts = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
this._userId = wrapper.readInt();
|
||||
this._value = wrapper.readString();
|
||||
this._answerCounts = new Map();
|
||||
|
||||
const count = wrapper.readInt();
|
||||
|
||||
for(let i = 0; i < count; i++)
|
||||
{
|
||||
const key = wrapper.readString();
|
||||
const value = wrapper.readInt();
|
||||
this._answerCounts.set(key, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public get userId():number
|
||||
{
|
||||
return this._userId;
|
||||
}
|
||||
|
||||
public get value():string
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
public get answerCounts():Map<string, number>
|
||||
{
|
||||
return this._answerCounts;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper';
|
||||
import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser';
|
||||
|
||||
export class QuestionFinishedParser implements IMessageParser
|
||||
{
|
||||
private _questionId:number;
|
||||
private _answerCounts:Map<string, number>;
|
||||
|
||||
flush(): boolean
|
||||
{
|
||||
this._questionId = -1;
|
||||
this._answerCounts = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
this._questionId = wrapper.readInt();
|
||||
this._answerCounts = new Map();
|
||||
const count = wrapper.readInt();
|
||||
|
||||
for(let i = 0; i < count; i++)
|
||||
{
|
||||
const key = wrapper.readString();
|
||||
const value = wrapper.readInt();
|
||||
this._answerCounts.set(key, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public get questionId():number
|
||||
{
|
||||
return this._questionId;
|
||||
}
|
||||
|
||||
public get answerCounts():Map<string, number>
|
||||
{
|
||||
return this._answerCounts;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
import { IMessageDataWrapper } from '../../../../../core';
|
||||
import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser';
|
||||
|
||||
export class QuestionParser implements IMessageParser
|
||||
{
|
||||
private _pollType:string = null;
|
||||
private _pollId= -1;
|
||||
private _questionId = -1;
|
||||
private _duration = -1;
|
||||
private _question:IQuestion = null;
|
||||
|
||||
flush(): boolean
|
||||
{
|
||||
this._pollType = null;
|
||||
this._pollId = -1;
|
||||
this._questionId = -1;
|
||||
this._duration = -1;
|
||||
this._question = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
this._pollType = wrapper.readString();
|
||||
this._pollId = wrapper.readInt();
|
||||
this._questionId = wrapper.readInt();
|
||||
this._duration = wrapper.readInt();
|
||||
|
||||
const questionId = wrapper.readInt();
|
||||
const questionNumber = wrapper.readInt();
|
||||
const questionType = wrapper.readInt();
|
||||
const questionContent = wrapper.readString();
|
||||
|
||||
this._question = { id: questionId, number: questionNumber, type: questionType, content: questionContent };
|
||||
|
||||
if(((this._question.type == 1) || (this._question.type == 2)))
|
||||
{
|
||||
this._question.selection_min = wrapper.readInt();
|
||||
const count = wrapper.readInt();
|
||||
this._question.selections = [];
|
||||
this._question.selection_values = [];
|
||||
this._question.selection_count = count;
|
||||
this._question.selection_max = count;
|
||||
|
||||
for(let i = 0; i < count; i++)
|
||||
{
|
||||
this._question.selection_values.push(wrapper.readString());
|
||||
this._question.selections.push(wrapper.readString());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public get pollType():string
|
||||
{
|
||||
return this._pollType;
|
||||
}
|
||||
|
||||
public get pollId():number
|
||||
{
|
||||
return this._pollId;
|
||||
}
|
||||
|
||||
public get questionId():number
|
||||
{
|
||||
return this._questionId;
|
||||
}
|
||||
|
||||
public get duration():number
|
||||
{
|
||||
return this._duration;
|
||||
}
|
||||
|
||||
public get question():IQuestion
|
||||
{
|
||||
return this._question;
|
||||
}
|
||||
}
|
||||
|
||||
interface IQuestion
|
||||
{
|
||||
id: number;
|
||||
number: number;
|
||||
type: number;
|
||||
content: string;
|
||||
selection_min?: number;
|
||||
selections?: string[];
|
||||
selection_values?: string[];
|
||||
selection_count?: number;
|
||||
selection_max?: number;
|
||||
}
|
8
src/nitro/communication/messages/parser/poll/index.ts
Normal file
8
src/nitro/communication/messages/parser/poll/index.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export * from './PollChoice';
|
||||
export * from './PollContentsParser';
|
||||
export * from './PollErrorParser';
|
||||
export * from './PollOfferParser';
|
||||
export * from './PollQuestion';
|
||||
export * from './QuestionAnsweredParser';
|
||||
export * from './QuestionFinishedParser';
|
||||
export * from './QuestionParser';
|
Loading…
Reference in New Issue
Block a user