mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-22 23:50:52 +01:00
#9 - OpenPetPackageRequestedMessageEvent, OpenPetPackageResultMessageEvent and PetPackageHandler added
This commit is contained in:
parent
c9307102f6
commit
2c65bda6ed
@ -1,4 +1,5 @@
|
||||
import { IPetFigureData, IRoomSession } from '../../api';
|
||||
import { IRoomSession } from '../../api';
|
||||
import { PetFigureData } from '../../nitro';
|
||||
import { RoomSessionEvent } from './RoomSessionEvent';
|
||||
|
||||
export class RoomSessionPetPackageEvent extends RoomSessionEvent
|
||||
@ -7,17 +8,17 @@ export class RoomSessionPetPackageEvent extends RoomSessionEvent
|
||||
public static RSOPPE_OPEN_PET_PACKAGE_RESULT: string = 'RSOPPE_OPEN_PET_PACKAGE_RESULT';
|
||||
|
||||
private _objectId: number = -1;
|
||||
private _figureData: IPetFigureData;
|
||||
private _figureData: PetFigureData;
|
||||
private _nameValidationStatus: number = 0;
|
||||
private _nameValidationInfo: string = null;
|
||||
|
||||
constructor(k: string, _arg_2: IRoomSession, _arg_3: number, _arg_4: IPetFigureData, _arg_5: number, _arg_6: string)
|
||||
constructor(petPackageName: string, session: IRoomSession, objectId: number, figureData: PetFigureData, nameValidationStatus: number, nameValidationInfo: string)
|
||||
{
|
||||
super(k, _arg_2);
|
||||
this._objectId = _arg_3;
|
||||
this._figureData = _arg_4;
|
||||
this._nameValidationStatus = _arg_5;
|
||||
this._nameValidationInfo = _arg_6;
|
||||
super(petPackageName, session);
|
||||
this._objectId = objectId;
|
||||
this._figureData = figureData;
|
||||
this._nameValidationStatus = nameValidationStatus;
|
||||
this._nameValidationInfo = nameValidationInfo;
|
||||
}
|
||||
|
||||
public get objectId(): number
|
||||
@ -25,7 +26,7 @@ export class RoomSessionPetPackageEvent extends RoomSessionEvent
|
||||
return this._objectId;
|
||||
}
|
||||
|
||||
public get figureData(): IPetFigureData
|
||||
public get figureData(): PetFigureData
|
||||
{
|
||||
return this._figureData;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -120,6 +120,8 @@ export class IncomingHeader
|
||||
public static PET_FIGURE_UPDATE = 1924;
|
||||
public static PET_INFO = 2901;
|
||||
public static PET_TRAINING_PANEL = 1164;
|
||||
public static PET_OPEN_PACKAGE_REQUESTED = 2380;
|
||||
public static PET_OPEN_PACKAGE_RESULT = 546;
|
||||
public static RECYCLER_PRIZES = 3164;
|
||||
public static ROOM_BAN_LIST = 1869;
|
||||
public static ROOM_BAN_REMOVE = 3429;
|
||||
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../api';
|
||||
import { MessageEvent } from '../../../../../events';
|
||||
import { OpenPetPackageRequestedMessageParser } from './../../parser';
|
||||
|
||||
export class OpenPetPackageRequestedMessageEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, OpenPetPackageRequestedMessageParser);
|
||||
}
|
||||
|
||||
public getParser(): OpenPetPackageRequestedMessageParser
|
||||
{
|
||||
return this.parser as OpenPetPackageRequestedMessageParser;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../api';
|
||||
import { MessageEvent } from '../../../../../events';
|
||||
import { OpenPetPackageResultMessageParser } from './../../parser';
|
||||
|
||||
export class OpenPetPackageResultMessageEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, OpenPetPackageResultMessageParser);
|
||||
}
|
||||
|
||||
public getParser(): OpenPetPackageResultMessageParser
|
||||
{
|
||||
return this.parser as OpenPetPackageResultMessageParser;
|
||||
}
|
||||
}
|
@ -1 +1,3 @@
|
||||
export * from './OpenPetPackageRequestedMessageEvent';
|
||||
export * from './OpenPetPackageResultMessageEvent';
|
||||
export * from './PetTrainingPanelMessageEvent';
|
||||
|
@ -0,0 +1,37 @@
|
||||
import { IMessageDataWrapper, IMessageParser } from '../../../../../api';
|
||||
import { PetFigureData } from '../../../../avatar';
|
||||
|
||||
export class OpenPetPackageRequestedMessageParser implements IMessageParser
|
||||
{
|
||||
private _objectId: number;
|
||||
private _figureData: PetFigureData;
|
||||
|
||||
flush(): boolean
|
||||
{
|
||||
this._objectId = -1;
|
||||
this._figureData = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
this._objectId = wrapper.readInt();
|
||||
|
||||
if(!wrapper.bytesAvailable) return true;
|
||||
|
||||
this._figureData = new PetFigureData(wrapper.readString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get objectId(): number
|
||||
{
|
||||
return this._objectId;
|
||||
}
|
||||
|
||||
public get figureData(): PetFigureData
|
||||
{
|
||||
return this._figureData;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
import { IMessageDataWrapper, IMessageParser } from '../../../../../api';
|
||||
|
||||
export class OpenPetPackageResultMessageParser implements IMessageParser
|
||||
{
|
||||
private _objectId: number;
|
||||
private _nameValidationStatus: number;
|
||||
private _nameValidationInfo: string;
|
||||
|
||||
flush(): boolean
|
||||
{
|
||||
this._objectId = 0;
|
||||
this._nameValidationStatus = 0;
|
||||
this._nameValidationInfo = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
this._objectId = wrapper.readInt();
|
||||
this._nameValidationStatus = wrapper.readInt();
|
||||
this._nameValidationInfo = wrapper.readString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get objectId(): number
|
||||
{
|
||||
return this._objectId;
|
||||
}
|
||||
|
||||
public get nameValidationStatus(): number
|
||||
{
|
||||
return this._nameValidationStatus;
|
||||
}
|
||||
|
||||
public get nameValidationInfo(): string
|
||||
{
|
||||
return this._nameValidationInfo;
|
||||
}
|
||||
}
|
@ -1 +1,3 @@
|
||||
export * from './OpenPetPackageRequestedMessageParser';
|
||||
export * from './OpenPetPackageResultMessageParser';
|
||||
export * from './PetTrainingMessageParser';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { INitroCommunicationManager, IRoomEngine, IRoomHandlerListener, IRoomSession, IRoomSessionManager } from '../../api';
|
||||
import { NitroManager } from '../../core';
|
||||
import { RoomEngineEvent, RoomSessionEvent } from '../../events';
|
||||
import { BaseHandler, GenericErrorHandler, PollHandler, RoomChatHandler, RoomDataHandler, RoomDimmerPresetsHandler, RoomPermissionsHandler, RoomPresentHandler, RoomSessionHandler, RoomUsersHandler, WordQuizHandler } from './handler';
|
||||
import { BaseHandler, GenericErrorHandler, PetPackageHandler, PollHandler, RoomChatHandler, RoomDataHandler, RoomDimmerPresetsHandler, RoomPermissionsHandler, RoomPresentHandler, RoomSessionHandler, RoomUsersHandler, WordQuizHandler } from './handler';
|
||||
import { RoomSession } from './RoomSession';
|
||||
|
||||
export class RoomSessionManager extends NitroManager implements IRoomSessionManager, IRoomHandlerListener
|
||||
@ -66,6 +66,7 @@ export class RoomSessionManager extends NitroManager implements IRoomSessionMana
|
||||
new GenericErrorHandler(connection, this),
|
||||
new WordQuizHandler(connection, this),
|
||||
new PollHandler(connection, this),
|
||||
new PetPackageHandler(connection, this),
|
||||
);
|
||||
}
|
||||
|
||||
|
45
src/nitro/session/handler/PetPackageHandler.ts
Normal file
45
src/nitro/session/handler/PetPackageHandler.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { IConnection, IRoomHandlerListener } from '../../../api';
|
||||
import { RoomSessionPetPackageEvent } from '../../../events';
|
||||
import { OpenPetPackageRequestedMessageEvent, OpenPetPackageResultMessageEvent } from '../../communication';
|
||||
import { BaseHandler } from './BaseHandler';
|
||||
|
||||
export class PetPackageHandler extends BaseHandler
|
||||
{
|
||||
constructor(connection: IConnection, listener: IRoomHandlerListener)
|
||||
{
|
||||
super(connection, listener);
|
||||
|
||||
connection.addMessageEvent(new OpenPetPackageRequestedMessageEvent(this.onOpenPetPackageRequested.bind(this)));
|
||||
connection.addMessageEvent(new OpenPetPackageResultMessageEvent(this.onOpenPetPackageResult.bind(this)));
|
||||
}
|
||||
|
||||
private onOpenPetPackageRequested(event: OpenPetPackageRequestedMessageEvent): void
|
||||
{
|
||||
if(!this.listener) return;
|
||||
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
const session = this.listener.getSession(this.roomId);
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPetPackageEvent(RoomSessionPetPackageEvent.RSOPPE_OPEN_PET_PACKAGE_REQUESTED, session, parser.objectId, parser.figureData, 0, null));
|
||||
}
|
||||
|
||||
private onOpenPetPackageResult(event: OpenPetPackageResultMessageEvent): void
|
||||
{
|
||||
if(!this.listener) return;
|
||||
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
const session = this.listener.getSession(this.roomId);
|
||||
|
||||
if(!session) return;
|
||||
|
||||
this.listener.events.dispatchEvent(new RoomSessionPetPackageEvent(RoomSessionPetPackageEvent.RSOPPE_OPEN_PET_PACKAGE_RESULT, session, parser.objectId, null, parser.nameValidationStatus, parser.nameValidationInfo));
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
export * from './BaseHandler';
|
||||
export * from './GenericErrorHandler';
|
||||
export * from './PetPackageHandler';
|
||||
export * from './PollHandler';
|
||||
export * from './RoomChatHandler';
|
||||
export * from './RoomDataHandler';
|
||||
|
Loading…
Reference in New Issue
Block a user