forked from billsonnn/nitro-renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
billsonnn#9 - GroupMembershipRequestedMessageEvent added
- Loading branch information
Showing
7 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/nitro/communication/messages/incoming/user/GroupMembershipRequestedMessageEvent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { IMessageEvent } from '../../../../../api'; | ||
import { MessageEvent } from '../../../../../events'; | ||
import { GroupMembershipRequestedMessageParser } from '../../parser'; | ||
|
||
export class GroupMembershipRequestedMessageEvent extends MessageEvent implements IMessageEvent | ||
{ | ||
constructor(callBack: Function) | ||
{ | ||
super(callBack, GroupMembershipRequestedMessageParser); | ||
} | ||
|
||
public getParser(): GroupMembershipRequestedMessageParser | ||
{ | ||
return this.parser as GroupMembershipRequestedMessageParser; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/nitro/communication/messages/incoming/user/MemberData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { IMessageDataWrapper } from '../../../../../api'; | ||
|
||
export class MemberData | ||
{ | ||
private static readonly TYPE_OWNER: number = 0; | ||
private static readonly TYPE_ADMIN: number = 1; | ||
private static readonly TYPE_PENDING: number = 2; | ||
private static readonly TYPE_MEMBER: number = 3; | ||
private static readonly TYPE_BLOCKED: number = 4; | ||
|
||
private _type: number; | ||
private _userId: number; | ||
private _userName: string; | ||
private _figure: string; | ||
private _memberSince: string; | ||
|
||
constructor(wrapper: IMessageDataWrapper) | ||
{ | ||
this._type = wrapper.readInt(); | ||
this._userId = wrapper.readInt(); | ||
this._userName = wrapper.readString(); | ||
this._figure = wrapper.readString(); | ||
this._memberSince = wrapper.readString(); | ||
} | ||
|
||
public get userId(): number | ||
{ | ||
return this._userId; | ||
} | ||
|
||
public get userName(): string | ||
{ | ||
return this._userName; | ||
} | ||
|
||
public get admin(): boolean | ||
{ | ||
return this._type == MemberData.TYPE_ADMIN; | ||
} | ||
|
||
public get owner(): boolean | ||
{ | ||
return this._type == MemberData.TYPE_OWNER; | ||
} | ||
|
||
public get pending(): boolean | ||
{ | ||
return this._type == MemberData.TYPE_PENDING; | ||
} | ||
|
||
public get member(): boolean | ||
{ | ||
return this._type != MemberData.TYPE_MEMBER; | ||
} | ||
|
||
public get blocked(): boolean | ||
{ | ||
return this._type == MemberData.TYPE_BLOCKED; | ||
} | ||
|
||
public get figure(): string | ||
{ | ||
return this._figure; | ||
} | ||
|
||
public get memberSince(): string | ||
{ | ||
return this._memberSince; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/nitro/communication/messages/parser/user/GroupMembershipRequestedMessageParser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { IMessageDataWrapper, IMessageParser } from '../../../../../api'; | ||
import { MemberData } from '../../incoming'; | ||
|
||
export class GroupMembershipRequestedMessageParser implements IMessageParser | ||
{ | ||
private _groupId: number; | ||
private _requester: MemberData; | ||
|
||
public flush(): boolean | ||
{ | ||
this._groupId = -1; | ||
this._requester = null; | ||
|
||
return true; | ||
} | ||
|
||
public parse(wrapper: IMessageDataWrapper): boolean | ||
{ | ||
if(!wrapper) return false; | ||
|
||
this._groupId = wrapper.readInt(); | ||
this._requester = new MemberData(wrapper); | ||
|
||
return true; | ||
} | ||
|
||
public get groupId(): number | ||
{ | ||
return this._groupId; | ||
} | ||
|
||
public get requester(): MemberData | ||
{ | ||
return this._requester; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters