mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-23 08:00:51 +01:00
Merge branch 'patch/fix-relationship-parser'
This commit is contained in:
commit
175bca56ea
@ -213,12 +213,12 @@ import { WiredValidationErrorEvent } from './messages/incoming/roomevents/WiredV
|
||||
import { AuthenticatedEvent } from './messages/incoming/security/AuthenticatedEvent';
|
||||
import { UserPerksEvent } from './messages/incoming/user/access/UserPerksEvent';
|
||||
import { UserPermissionsEvent } from './messages/incoming/user/access/UserPermissionsEvent';
|
||||
import { RelationshipStatusInfoEvent } from './messages/incoming/user/data/RelationshipStatusInfoEvent';
|
||||
import { UserCurrentBadgesEvent } from './messages/incoming/user/data/UserCurrentBadgesEvent';
|
||||
import { UserFigureEvent } from './messages/incoming/user/data/UserFigureEvent';
|
||||
import { UserInfoEvent } from './messages/incoming/user/data/UserInfoEvent';
|
||||
import { UserNameChangeMessageEvent } from './messages/incoming/user/data/UserNameChangeMessageEvent';
|
||||
import { UserProfileEvent } from './messages/incoming/user/data/UserProfileEvent';
|
||||
import { UserRelationshipsEvent } from './messages/incoming/user/data/UserRelationshipsEvent';
|
||||
import { UserSettingsEvent } from './messages/incoming/user/data/UserSettingsEvent';
|
||||
import { IgnoredUsersEvent } from './messages/incoming/user/IgnoredUsersEvent';
|
||||
import { IgnoreResultEvent } from './messages/incoming/user/IgnoreResultEvent';
|
||||
@ -736,7 +736,7 @@ export class NitroMessages implements IMessageConfiguration
|
||||
this._events.set(IncomingHeader.UNIT_CHANGE_NAME, UserNameChangeMessageEvent);
|
||||
this._events.set(IncomingHeader.USER_SETTINGS, UserSettingsEvent);
|
||||
this._events.set(IncomingHeader.USER_PROFILE, UserProfileEvent);
|
||||
this._events.set(IncomingHeader.MESSENGER_RELATIONSHIPS, UserRelationshipsEvent);
|
||||
this._events.set(IncomingHeader.MESSENGER_RELATIONSHIPS, RelationshipStatusInfoEvent);
|
||||
|
||||
// GIFTS
|
||||
this._events.set(IncomingHeader.GIFT_OPENED, PresentOpenedMessageEvent);
|
||||
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../../core/communication/messages/IMessageEvent';
|
||||
import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent';
|
||||
import { RelationshipStatusInfoMessageParser } from '../../../parser/user/data/RelationshipStatusInfoMessageParser';
|
||||
|
||||
export class RelationshipStatusInfoEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, RelationshipStatusInfoMessageParser);
|
||||
}
|
||||
|
||||
public getParser(): RelationshipStatusInfoMessageParser
|
||||
{
|
||||
return this.parser as RelationshipStatusInfoMessageParser;
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
import { IMessageEvent } from '../../../../../../core/communication/messages/IMessageEvent';
|
||||
import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent';
|
||||
import { UserRelationshipsParser } from '../../../parser/user/data/UserRelationshipsParser';
|
||||
|
||||
export class UserRelationshipsEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, UserRelationshipsParser);
|
||||
}
|
||||
|
||||
public getParser(): UserRelationshipsParser
|
||||
{
|
||||
return this.parser as UserRelationshipsParser;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
export * from './RelationshipStatusInfoEvent';
|
||||
export * from './UserCurrentBadgesEvent';
|
||||
export * from './UserFigureEvent';
|
||||
export * from './UserInfoEvent';
|
||||
export * from './UserNameChangeMessageEvent';
|
||||
export * from './UserProfileEvent';
|
||||
export * from './UserRelationshipsEvent';
|
||||
export * from './UserSettingsEvent';
|
||||
|
@ -0,0 +1,68 @@
|
||||
import { IMessageDataWrapper } from '../../../../../../core/communication/messages/IMessageDataWrapper';
|
||||
import { RelationshipStatusEnum } from '../../../../../enums/RelationshipStatusEnum';
|
||||
|
||||
export class RelationshipStatusInfo
|
||||
{
|
||||
private _relationshipStatusType: RelationshipStatusEnum;
|
||||
private _friendCount: number;
|
||||
private _randomFriendId: number;
|
||||
private _randomFriendName: string;
|
||||
private _randomFriendFigure: string;
|
||||
|
||||
constructor(wrapper: IMessageDataWrapper)
|
||||
{
|
||||
if(!wrapper) throw new Error('invalid_wrapper');
|
||||
|
||||
this.flush();
|
||||
this.parse(wrapper);
|
||||
}
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._relationshipStatusType = RelationshipStatusEnum.NONE;
|
||||
this._friendCount = 0;
|
||||
this._randomFriendId = 0;
|
||||
this._randomFriendFigure = null;
|
||||
this._randomFriendName = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
if(!wrapper) return false;
|
||||
|
||||
this._relationshipStatusType = wrapper.readInt();
|
||||
this._friendCount = wrapper.readInt();
|
||||
this._randomFriendId = wrapper.readInt();
|
||||
this._randomFriendName = wrapper.readString();
|
||||
this._randomFriendFigure = wrapper.readString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get relationshipStatusType(): RelationshipStatusEnum
|
||||
{
|
||||
return this._relationshipStatusType;
|
||||
}
|
||||
|
||||
public get friendCount(): number
|
||||
{
|
||||
return this._friendCount;
|
||||
}
|
||||
|
||||
public get randomFriendId(): number
|
||||
{
|
||||
return this._randomFriendId;
|
||||
}
|
||||
|
||||
public get randomFriendName(): string
|
||||
{
|
||||
return this._randomFriendName;
|
||||
}
|
||||
|
||||
public get randomFriendFigure(): string
|
||||
{
|
||||
return this._randomFriendFigure;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
import { IMessageDataWrapper } from '../../../../../../core/communication/messages/IMessageDataWrapper';
|
||||
import { IMessageParser } from '../../../../../../core/communication/messages/IMessageParser';
|
||||
import { AdvancedMap } from '../../../../../../core/utils/AdvancedMap';
|
||||
import { RelationshipStatusEnum } from '../../../../../enums/RelationshipStatusEnum';
|
||||
import { RelationshipStatusInfo } from './RelationshipStatusInfo';
|
||||
|
||||
export class RelationshipStatusInfoMessageParser implements IMessageParser
|
||||
{
|
||||
private _userId: number;
|
||||
private _relationshipStatusMap: AdvancedMap<RelationshipStatusEnum, RelationshipStatusInfo>;
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._userId = 0;
|
||||
this._relationshipStatusMap = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
if(!wrapper) return false;
|
||||
|
||||
this._userId = wrapper.readInt();
|
||||
this._relationshipStatusMap = new AdvancedMap();
|
||||
|
||||
const relationshipsCount = wrapper.readInt();
|
||||
|
||||
for(let i = 0; i < relationshipsCount; i++)
|
||||
{
|
||||
const relationship = new RelationshipStatusInfo(wrapper);
|
||||
|
||||
this._relationshipStatusMap.add(relationship.relationshipStatusType, relationship);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get userId(): number
|
||||
{
|
||||
return this._userId;
|
||||
}
|
||||
|
||||
public get relationshipStatusMap(): AdvancedMap<RelationshipStatusEnum, RelationshipStatusInfo>
|
||||
{
|
||||
return this._relationshipStatusMap;
|
||||
}
|
||||
}
|
@ -15,7 +15,8 @@ export class UserProfileParser implements IMessageParser
|
||||
private _requestSent: boolean;
|
||||
private _isOnline: boolean;
|
||||
private _groups: GroupDataParser[];
|
||||
private _lastVisit: number;
|
||||
private _secondsSinceLastVisit: number;
|
||||
private _openProfileWindow: boolean;
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
@ -30,7 +31,8 @@ export class UserProfileParser implements IMessageParser
|
||||
this._requestSent = false;
|
||||
this._isOnline = false;
|
||||
this._groups = [];
|
||||
this._lastVisit = 0;
|
||||
this._secondsSinceLastVisit = 0;
|
||||
this._openProfileWindow = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -49,16 +51,15 @@ export class UserProfileParser implements IMessageParser
|
||||
this._isMyFriend = wrapper.readBoolean();
|
||||
this._requestSent = wrapper.readBoolean();
|
||||
this._isOnline = wrapper.readBoolean();
|
||||
let groupsCount = wrapper.readInt();
|
||||
const groupsCount = wrapper.readInt();
|
||||
|
||||
while(groupsCount > 0)
|
||||
for(let i = 0; i < groupsCount; i++)
|
||||
{
|
||||
this._groups.push(new GroupDataParser(wrapper));
|
||||
|
||||
groupsCount--;
|
||||
}
|
||||
|
||||
this._lastVisit = wrapper.readInt();
|
||||
this._secondsSinceLastVisit = wrapper.readInt();
|
||||
this._openProfileWindow = wrapper.readBoolean();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -118,8 +119,13 @@ export class UserProfileParser implements IMessageParser
|
||||
return this._groups;
|
||||
}
|
||||
|
||||
public get lastVisit(): number
|
||||
public get secondsSinceLastVisit(): number
|
||||
{
|
||||
return this._lastVisit;
|
||||
return this._secondsSinceLastVisit;
|
||||
}
|
||||
|
||||
public get openProfileWindow(): boolean
|
||||
{
|
||||
return this._openProfileWindow;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
import { IMessageDataWrapper } from '../../../../../../core/communication/messages/IMessageDataWrapper';
|
||||
import { RelationshipStatusEnum } from '../../../../../enums/RelationshipStatusEnum';
|
||||
|
||||
export class UserRelationshipDataParser
|
||||
{
|
||||
private _level: RelationshipStatusEnum;
|
||||
private _userId: number;
|
||||
private _username: string;
|
||||
private _figure: string;
|
||||
|
||||
constructor(wrapper: IMessageDataWrapper)
|
||||
{
|
||||
if(!wrapper) throw new Error('invalid_wrapper');
|
||||
|
||||
this.flush();
|
||||
this.parse(wrapper);
|
||||
}
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._level = RelationshipStatusEnum.NONE;
|
||||
this._userId = 0;
|
||||
this._username = null;
|
||||
this._figure = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
if(!wrapper) return false;
|
||||
|
||||
this._level = wrapper.readInt();
|
||||
wrapper.readInt();
|
||||
this._userId = wrapper.readInt();
|
||||
this._username = wrapper.readString();
|
||||
this._figure = wrapper.readString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get level(): RelationshipStatusEnum
|
||||
{
|
||||
return this._level;
|
||||
}
|
||||
|
||||
public get userId(): number
|
||||
{
|
||||
return this._userId;
|
||||
}
|
||||
|
||||
public get username(): string
|
||||
{
|
||||
return this._username;
|
||||
}
|
||||
|
||||
public get figure(): string
|
||||
{
|
||||
return this._figure;
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
import { IMessageDataWrapper } from '../../../../../../core/communication/messages/IMessageDataWrapper';
|
||||
import { IMessageParser } from '../../../../../../core/communication/messages/IMessageParser';
|
||||
import { RelationshipStatusEnum } from '../../../../../enums/RelationshipStatusEnum';
|
||||
import { UserRelationshipDataParser } from './UserRelationshipDataParser';
|
||||
|
||||
export class UserRelationshipsParser implements IMessageParser
|
||||
{
|
||||
private _id: number;
|
||||
private _hearts: UserRelationshipDataParser[];
|
||||
private _smiles: UserRelationshipDataParser[];
|
||||
private _bobbas: UserRelationshipDataParser[];
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._id = 0;
|
||||
this._hearts = [];
|
||||
this._smiles = [];
|
||||
this._bobbas = [];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
if(!wrapper) return false;
|
||||
|
||||
this._id = wrapper.readInt();
|
||||
let relationshipsCount = wrapper.readInt();
|
||||
|
||||
while(relationshipsCount > 0)
|
||||
{
|
||||
const relationship = new UserRelationshipDataParser(wrapper);
|
||||
|
||||
if(relationship.level === RelationshipStatusEnum.HEART)
|
||||
{
|
||||
this._hearts.push(relationship);
|
||||
}
|
||||
else if(relationship.level === RelationshipStatusEnum.SMILE)
|
||||
{
|
||||
this._smiles.push(relationship);
|
||||
}
|
||||
else if(relationship.level === RelationshipStatusEnum.BOBBA)
|
||||
{
|
||||
this._bobbas.push(relationship);
|
||||
}
|
||||
|
||||
relationshipsCount--;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get id(): number
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public get hearts(): UserRelationshipDataParser[]
|
||||
{
|
||||
return this._hearts;
|
||||
}
|
||||
|
||||
public get smiles(): UserRelationshipDataParser[]
|
||||
{
|
||||
return this._smiles;
|
||||
}
|
||||
|
||||
public get bobbas(): UserRelationshipDataParser[]
|
||||
{
|
||||
return this._bobbas;
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
export * from './RelationshipStatusInfo';
|
||||
export * from './RelationshipStatusInfoMessageParser';
|
||||
export * from './UserCurrentBadgesParser';
|
||||
export * from './UserFigureParser';
|
||||
export * from './UserInfoDataParser';
|
||||
export * from './UserInfoParser';
|
||||
export * from './UserNameChangeMessageParser';
|
||||
export * from './UserProfileParser';
|
||||
export * from './UserRelationshipDataParser';
|
||||
export * from './UserRelationshipsParser';
|
||||
export * from './UserSettingsParser';
|
||||
|
Loading…
Reference in New Issue
Block a user