You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 15:06:20 +00:00
feat(messenger): read-receipt packets (MarkConsoleRead + ConsoleReadReceipt)
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -113,6 +113,7 @@ export class IncomingHeader
|
|||||||
public static MESSENGER_REQUESTS = 280;
|
public static MESSENGER_REQUESTS = 280;
|
||||||
public static MESSENGER_SEARCH = 973;
|
public static MESSENGER_SEARCH = 973;
|
||||||
public static MESSENGER_UPDATE = 2800;
|
public static MESSENGER_UPDATE = 2800;
|
||||||
|
public static CONSOLE_READ_RECEIPT = 4086;
|
||||||
public static MODERATION_REPORT_DISABLED = 1651;
|
public static MODERATION_REPORT_DISABLED = 1651;
|
||||||
public static MODERATION_TOOL = 2696;
|
public static MODERATION_TOOL = 2696;
|
||||||
public static MODERATION_USER_INFO = 2866;
|
public static MODERATION_USER_INFO = 2866;
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { IMessageEvent } from '@nitrots/api';
|
||||||
|
import { MessageEvent } from '@nitrots/events';
|
||||||
|
import { ConsoleReadReceiptParser } from '../../parser';
|
||||||
|
|
||||||
|
export class ConsoleReadReceiptEvent extends MessageEvent implements IMessageEvent
|
||||||
|
{
|
||||||
|
constructor(callBack: Function)
|
||||||
|
{
|
||||||
|
super(callBack, ConsoleReadReceiptParser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getParser(): ConsoleReadReceiptParser
|
||||||
|
{
|
||||||
|
return this.parser as ConsoleReadReceiptParser;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
export * from './AcceptFriendResultEvent';
|
export * from './AcceptFriendResultEvent';
|
||||||
|
export * from './ConsoleReadReceiptEvent';
|
||||||
export * from './FindFriendsProcessResultEvent';
|
export * from './FindFriendsProcessResultEvent';
|
||||||
export * from './FollowFriendFailedEvent';
|
export * from './FollowFriendFailedEvent';
|
||||||
export * from './FriendListFragmentEvent';
|
export * from './FriendListFragmentEvent';
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ export class OutgoingHeader
|
|||||||
public static RENAME_FRIEND_CATEGORY = 4082;
|
public static RENAME_FRIEND_CATEGORY = 4082;
|
||||||
public static REMOVE_FRIEND_CATEGORY = 4083;
|
public static REMOVE_FRIEND_CATEGORY = 4083;
|
||||||
public static MOVE_FRIEND_TO_CATEGORY = 4084;
|
public static MOVE_FRIEND_TO_CATEGORY = 4084;
|
||||||
|
public static MARK_CONSOLE_READ = 4085;
|
||||||
public static MOD_TOOL_USER_INFO = 3295;
|
public static MOD_TOOL_USER_INFO = 3295;
|
||||||
public static GET_USER_FLAT_CATS = 3027;
|
public static GET_USER_FLAT_CATS = 3027;
|
||||||
public static NAVIGATOR_INIT = 2110;
|
public static NAVIGATOR_INIT = 2110;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { IMessageComposer } from '@nitrots/api';
|
||||||
|
|
||||||
|
export class MarkConsoleReadComposer implements IMessageComposer<ConstructorParameters<typeof MarkConsoleReadComposer>>
|
||||||
|
{
|
||||||
|
private _data: ConstructorParameters<typeof MarkConsoleReadComposer>;
|
||||||
|
|
||||||
|
constructor(peerId: number)
|
||||||
|
{
|
||||||
|
this._data = [ peerId ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public getMessageArray()
|
||||||
|
{
|
||||||
|
return this._data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public dispose(): void
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
export * from './AcceptFriendMessageComposer';
|
export * from './AcceptFriendMessageComposer';
|
||||||
|
export * from './MarkConsoleReadComposer';
|
||||||
export * from './AddFriendCategoryComposer';
|
export * from './AddFriendCategoryComposer';
|
||||||
export * from './DeclineFriendMessageComposer';
|
export * from './DeclineFriendMessageComposer';
|
||||||
export * from './FindNewFriendsMessageComposer';
|
export * from './FindNewFriendsMessageComposer';
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
|
||||||
|
|
||||||
|
export class ConsoleReadReceiptParser implements IMessageParser
|
||||||
|
{
|
||||||
|
private _readerId: number;
|
||||||
|
|
||||||
|
public flush(): boolean
|
||||||
|
{
|
||||||
|
this._readerId = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public parse(wrapper: IMessageDataWrapper): boolean
|
||||||
|
{
|
||||||
|
if(!wrapper) return false;
|
||||||
|
|
||||||
|
this._readerId = wrapper.readInt();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get readerId(): number
|
||||||
|
{
|
||||||
|
return this._readerId;
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { BinaryReader, BinaryWriter } from '@nitrots/utils';
|
||||||
|
import { ConsoleReadReceiptParser } from '../ConsoleReadReceiptParser';
|
||||||
|
|
||||||
|
class TestWrapper
|
||||||
|
{
|
||||||
|
constructor(private reader: BinaryReader) {}
|
||||||
|
readByte() { return this.reader.readByte(); }
|
||||||
|
readShort() { return this.reader.readShort(); }
|
||||||
|
readInt() { return this.reader.readInt(); }
|
||||||
|
readString() { const len = this.reader.readShort(); return this.reader.readBytes(len).toString(); }
|
||||||
|
header = 0;
|
||||||
|
get bytesAvailable() { return this.reader.remaining() > 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('ConsoleReadReceiptParser', () =>
|
||||||
|
{
|
||||||
|
it('parses the reader id', () =>
|
||||||
|
{
|
||||||
|
const w = new BinaryWriter();
|
||||||
|
w.writeInt(42);
|
||||||
|
const parser = new ConsoleReadReceiptParser();
|
||||||
|
parser.flush();
|
||||||
|
parser.parse(new TestWrapper(new BinaryReader(w.getBuffer())) as any);
|
||||||
|
expect(parser.readerId).toBe(42);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
export * from './AcceptFriendFailureData';
|
export * from './AcceptFriendFailureData';
|
||||||
|
export * from './ConsoleReadReceiptParser';
|
||||||
export * from './AcceptFriendResultParser';
|
export * from './AcceptFriendResultParser';
|
||||||
export * from './FindFriendsProcessResultParser';
|
export * from './FindFriendsProcessResultParser';
|
||||||
export * from './FollowFriendFailedParser';
|
export * from './FollowFriendFailedParser';
|
||||||
|
|||||||
Reference in New Issue
Block a user