This commit is contained in:
rosetta
2026-01-30 05:01:05 +02:00
commit 83f38dc63f
327 changed files with 18725 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketAppUpdate extends Packet {
private url: string = "";
private version: string = "";
private kernelVersionRequired: string = "";
public getPacketId(): number {
return 0x0E;
}
public _receive(stream: Stream): void {
this.url = stream.readString();
this.version = stream.readString();
this.kernelVersionRequired = stream.readString();
}
public _send(): Promise<Stream> | Stream {
let stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.url);
stream.writeString(this.version);
stream.writeString(this.kernelVersionRequired);
return stream;
}
public getUrl(): string {
return this.url;
}
public setUrl(url: string): void {
this.url = url;
}
public getVersion(): string {
return this.version;
}
public setVersion(version: string): void {
this.version = version;
}
public getKernelVersionRequired(): string {
return this.kernelVersionRequired;
}
public setKernelVersionRequired(kernelVersionRequired: string): void {
this.kernelVersionRequired = kernelVersionRequired;
}
}

View File

@@ -0,0 +1,77 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketAvatar extends Packet {
private privateKey : string = "";
private fromPublicKey: string = "";
private toPublicKey: string = "";
private blob: string = "";
private chachaKey: string = "";
public getPacketId(): number {
return 0x0C;
}
public _receive(stream: Stream): void {
this.privateKey = stream.readString();
this.fromPublicKey = stream.readString();
this.toPublicKey = stream.readString();
this.chachaKey = stream.readString();
this.blob = stream.readString();
}
public _send(): Promise<Stream> | Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.privateKey);
stream.writeString(this.fromPublicKey);
stream.writeString(this.toPublicKey);
stream.writeString(this.chachaKey);
stream.writeString(this.blob);
return stream;
}
public setFromPublicKey(fromPublicKey: string): void {
this.fromPublicKey = fromPublicKey;
}
public setToPublicKey(toPublicKey: string): void {
this.toPublicKey = toPublicKey;
}
public getFromPublicKey(): string {
return this.fromPublicKey;
}
public getToPublicKey(): string {
return this.toPublicKey;
}
public setPrivateKey(hash: string): void {
this.privateKey = hash;
}
public getPrivateKey(): string {
return this.privateKey;
}
public setBlob(blob: string): void {
this.blob = blob;
}
public getBlob(): string {
return this.blob;
}
public setChachaKey(key: string): void {
this.chachaKey = key;
}
public getChachaKey(): string {
return this.chachaKey;
}
}

View File

@@ -0,0 +1,31 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketCreateGroup extends Packet {
private groupId: string = "";
public getPacketId(): number {
return 0x11;
}
public _receive(stream: Stream): void {
this.groupId = stream.readString();
}
public _send(): Promise<Stream> | Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.groupId);
return stream;
}
public setGroupId(groupId: string) {
this.groupId = groupId;
}
public getGroupId(): string {
return this.groupId;
}
}

View File

@@ -0,0 +1,42 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketDelivery extends Packet {
private messageId: string = "";
private toPublicKey: string = "";
public getPacketId(): number {
return 0x08;
}
public _receive(stream: Stream): void {
this.toPublicKey = stream.readString();
this.messageId = stream.readString();
}
public _send(): Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.toPublicKey);
stream.writeString(this.messageId);
return stream;
}
public setMessageId(messageId: string) {
this.messageId = messageId;
}
public getMessageId(): string {
return this.messageId;
}
public setToPublicKey(toPublicKey: string) {
this.toPublicKey = toPublicKey;
}
public getToPublicKey(): string {
return this.toPublicKey;
}
}

View File

@@ -0,0 +1,42 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketGroupBan extends Packet {
private groupId: string = "";
private publicKey: string = "";
public getPacketId(): number {
return 0x16;
}
public _receive(stream: Stream): void {
this.groupId = stream.readString();
this.publicKey = stream.readString();
}
public _send(): Promise<Stream> | Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.groupId);
stream.writeString(this.publicKey);
return stream;
}
public getGroupId(): string {
return this.groupId;
}
public getPublicKey(): string {
return this.publicKey;
}
public setGroupId(groupId: string): void {
this.groupId = groupId;
}
public setPublicKey(publicKey: string): void {
this.publicKey = publicKey;
}
}

View File

@@ -0,0 +1,50 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketGroupInfo extends Packet {
private groupId: string = "";
private members: string[] = [];
public getPacketId(): number {
return 0x12;
}
public _receive(stream: Stream): void {
this.groupId = stream.readString();
const membersCount = stream.readInt16();
this.members = [];
for(let i = 0; i < membersCount; i++) {
this.members.push(stream.readString());
}
}
public _send(): Promise<Stream> | Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.groupId);
stream.writeInt16(this.members.length);
this.members.forEach((member) => {
stream.writeString(member);
});
return stream;
}
public getGroupId(): string {
return this.groupId;
}
public setGroupId(groupId: string): void {
this.groupId = groupId;
}
public setMembers(members: string[]): void {
this.members = members;
}
public getMembers(): string[] {
return this.members;
}
}

View File

@@ -0,0 +1,60 @@
import Packet from "../packet"
import Stream from "../stream";
export enum GroupStatus {
JOINED = 0,
INVALID = 1,
NOT_JOINED = 2,
BANNED = 3
}
export class PacketGroupInviteInfo extends Packet {
private groupId: string = "";
private membersCount = 0;
private groupStatus: GroupStatus = GroupStatus.NOT_JOINED;
public getPacketId(): number {
return 0x13;
}
public _receive(stream: Stream): void {
this.groupId = stream.readString();
this.membersCount = stream.readInt16();
this.groupStatus = stream.readInt8();
}
public _send(): Promise<Stream> | Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.groupId);
stream.writeInt16(this.membersCount);
stream.writeInt8(this.groupStatus);
return stream;
}
public setGroupId(groupId: string) {
this.groupId = groupId;
}
public getGroupId(): string {
return this.groupId;
}
public setMembersCount(count: number) {
this.membersCount = count;
}
public getMembersCount(): number {
return this.membersCount;
}
public setGroupStatus(status: GroupStatus) {
this.groupStatus = status;
}
public getGroupStatus(): GroupStatus {
return this.groupStatus;
}
}

View File

@@ -0,0 +1,49 @@
import Packet from "../packet";
import Stream from "../stream";
export enum GroupStatus {
JOINED = 0,
INVALID = 1,
NOT_JOINED = 2,
BANNED = 3
}
export class PacketGroupJoin extends Packet {
private groupId: string = "";
private groupStatus: GroupStatus = GroupStatus.NOT_JOINED;
public getPacketId(): number {
return 0x14;
}
public _receive(stream: Stream): void {
this.groupId = stream.readString();
this.groupStatus = stream.readInt8();
}
public _send(): Promise<Stream> | Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.groupId);
stream.writeInt8(this.groupStatus);
return stream;
}
public setGroupId(groupId: string) {
this.groupId = groupId;
}
public getGroupId(): string {
return this.groupId;
}
public setGroupStatus(groupStatus: GroupStatus) {
this.groupStatus = groupStatus;
}
public getGroupStatus(): GroupStatus {
return this.groupStatus;
}
}

View File

@@ -0,0 +1,31 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketGroupLeave extends Packet {
private groupId: string = "";
public getPacketId(): number {
return 0x15;
}
public _receive(stream: Stream): void {
this.groupId = stream.readString();
}
public _send(): Promise<Stream> | Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.groupId);
return stream;
}
public setGroupId(groupId: string) {
this.groupId = groupId;
}
public getGroupId(): string {
return this.groupId;
}
}

View File

@@ -0,0 +1,113 @@
import Packet from "../packet";
import Stream from "../stream";
export enum HandshakeState {
COMPLETED,
NEED_DEVICE_VERIFICATION
}
export interface Device {
deviceId: string;
deviceName: string;
}
/**
* Hadshake packet
* ID: 0x00
*
* The handshake packet is the first packet sent by the client to the server.
* It contains the hash of the client's public key and the public key itself.
*/
export default class PacketHandshake extends Packet {
private privateKey: string = "";
private publicKey: string = "";
private protocolVersion: number = 1;
/**
* Interval seconds
*/
private heartbeatInterval : number = 15;
private device: Device = {
deviceId: "",
deviceName: ""
};
private handshakeState:
HandshakeState = HandshakeState.NEED_DEVICE_VERIFICATION;
public getPacketId(): number {
return 0x00;
}
public _receive(stream: Stream): void {
this.privateKey = stream.readString();
this.publicKey = stream.readString();
this.protocolVersion = stream.readInt8();
this.heartbeatInterval = stream.readInt8();
this.device = {
deviceId: stream.readString(),
deviceName: stream.readString()
}
this.handshakeState = stream.readInt8();
}
public _send(): Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.privateKey);
stream.writeString(this.publicKey);
stream.writeInt8(this.protocolVersion);
stream.writeInt8(this.heartbeatInterval);
stream.writeString(this.device.deviceId);
stream.writeString(this.device.deviceName);
stream.writeInt8(this.handshakeState);
return stream;
}
public getPrivateKey(): string {
return this.privateKey;
}
public getPublicKey(): string {
return this.publicKey;
}
public setPrivateKey(privateKey: string): void {
this.privateKey = privateKey;
}
public setPublicKey(publicKey: string): void {
this.publicKey = publicKey;
}
public getProtocolVersion(): number {
return this.protocolVersion;
}
public setProtocolVersion(protocolVersion: number): void {
this.protocolVersion = protocolVersion;
}
public getHeartbeatInterval(): number {
return this.heartbeatInterval;
}
public setHeartbeatInterval(heartbeatInterval: number): void {
this.heartbeatInterval = heartbeatInterval;
}
public getDevice(): Device {
return this.device;
}
public setDevice(device: Device): void {
this.device = device;
}
public getHandshakeState(): HandshakeState {
return this.handshakeState;
}
public setHandshakeState(handshakeState: HandshakeState): void {
this.handshakeState = handshakeState;
}
}

View File

@@ -0,0 +1,43 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketKernelUpdate extends Packet {
private url: string = "";
private version: string = "";
public getPacketId(): number {
return 0x0D;
}
public _receive(stream: Stream): void {
this.url = stream.readString();
this.version = stream.readString();
}
public _send(): Promise<Stream> | Stream {
let stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.url);
stream.writeString(this.version);
return stream;
}
public getUrl(): string {
return this.url;
}
public setUrl(url: string): void {
this.url = url;
}
public getVersion(): string {
return this.version;
}
public setVersion(version: string): void {
this.version = version;
}
}

View File

@@ -0,0 +1,150 @@
import Packet from "../packet";
import Stream from "../stream";
export enum AttachmentType {
IMAGE = 0,
MESSAGES = 1,
FILE = 2,
AVATAR = 3
}
export interface Attachment {
id: string;
blob: string;
type: AttachmentType;
preview: string;
}
export class PacketMessage extends Packet {
private fromPublicKey: string = "";
private toPublicKey: string = "";
private content: string = "";
private chachaKey: string = "";
private timestamp: number = 0;
private privateKey: string = "";
private messageId: string = "";
/**
* Закодированный с помощью AES ключ chacha, нужен
* для последующей синхронизации своих же сообщений
*/
private aesChachaKey: string = "";
private attachments: Attachment[] = [];
public getPacketId(): number {
return 0x06;
}
public _receive(stream: Stream): void {
this.fromPublicKey = stream.readString();
this.toPublicKey = stream.readString();
this.content = stream.readString();
this.chachaKey = stream.readString();
this.timestamp = stream.readInt64();
this.privateKey = stream.readString();
this.messageId = stream.readString();
let attachmentsCount = stream.readInt8();
for(let i = 0; i < attachmentsCount; i++){
let id = stream.readString();
let preview = stream.readString();
let blob = stream.readString();
let type = stream.readInt8() as AttachmentType;
this.attachments.push({id, preview, type, blob});
}
this.aesChachaKey = stream.readString();
}
public async _send(): Promise<Stream> {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.fromPublicKey);
stream.writeString(this.toPublicKey);
stream.writeString(this.content);
stream.writeString(this.chachaKey);
stream.writeInt64(this.timestamp);
stream.writeString(this.privateKey);
stream.writeString(this.messageId);
stream.writeInt8(this.attachments.length);
for(let i = 0; i < this.attachments.length; i++){
stream.writeString(this.attachments[i].id);
stream.writeString(this.attachments[i].preview);
stream.writeString(this.attachments[i].blob);
stream.writeInt8(this.attachments[i].type);
}
stream.writeString(this.aesChachaKey);
return stream;
}
public setAttachments(attachments: Attachment[]): void {
this.attachments = attachments;
}
public getAttachments(): Attachment[] {
return this.attachments;
}
public setMessageId(messageId: string): void {
this.messageId = messageId;
}
public getMessageId(): string {
return this.messageId;
}
public setTimestamp(timestamp: number): void {
this.timestamp = timestamp;
}
public getTimestamp() : number {
return this.timestamp;
}
public getFromPublicKey(): string {
return this.fromPublicKey;
}
public getToPublicKey(): string {
return this.toPublicKey;
}
public getContent(): string {
return this.content;
}
public getChachaKey(): string {
return this.chachaKey;
}
public setFromPublicKey(fromPublicKey: string): void {
this.fromPublicKey = fromPublicKey;
}
public setToPublicKey(toPublicKey: string): void {
this.toPublicKey = toPublicKey;
}
public setContent(content: string): void {
this.content = content;
}
public setChachaKey(chachaKey: string): void {
this.chachaKey = chachaKey;
}
public setPrivateKey(privateKey: string): void {
this.privateKey = privateKey;
}
public getPrivateKey(): string {
return this.privateKey;
}
public getAesChachaKey() : string {
return this.aesChachaKey;
}
public setAesChachaKey(aesChachaKey: string) {
this.aesChachaKey = aesChachaKey;
}
}

View File

@@ -0,0 +1,58 @@
import Packet from "../packet";
import Stream from "../stream";
export enum OnlineState {
ONLINE,
OFFLINE
}
export interface PublicKeyOnlineState {
publicKey: string;
state: OnlineState;
}
export class PacketOnlineState extends Packet {
private publicKeysState: PublicKeyOnlineState[] = [];
public getPacketId(): number {
return 0x05;
}
public _receive(stream: Stream): void {
const publicKeyCount = stream.readInt8();
for (let i = 0; i < publicKeyCount; i++) {
const publicKey = stream.readString();
const state = stream.readBoolean() ? OnlineState.ONLINE : OnlineState.OFFLINE;
this.publicKeysState.push({ publicKey, state });
}
}
public _send(): Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeInt8(this.publicKeysState.length);
for (const publicKeyState of this.publicKeysState) {
stream.writeString(publicKeyState.publicKey);
stream.writeBoolean(publicKeyState.state === OnlineState.ONLINE);
}
return stream;
}
public addPublicKeyState(publicKey: string, state: OnlineState): void {
this.publicKeysState.push({ publicKey, state });
}
public getPublicKeysState(): PublicKeyOnlineState[] {
return this.publicKeysState;
}
public setPublicKeysState(publicKeysState: PublicKeyOnlineState[]): void {
this.publicKeysState = publicKeysState;
}
}

View File

@@ -0,0 +1,59 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketOnlineSubscribe extends Packet {
private privateKey : string = "";
private publicKeys: string[] = [];
public getPacketId(): number {
return 0x04;
}
public _receive(stream: Stream): void {
this.privateKey = stream.readString();
const keysCount = stream.readInt16();
for (let i = 0; i < keysCount; i++) {
this.publicKeys.push(stream.readString());
}
}
public _send(): Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.privateKey);
stream.writeInt16(this.publicKeys.length);
for (const key of this.publicKeys) {
stream.writeString(key);
}
return stream;
}
public getPrivateKey(): string {
return this.privateKey;
}
public setPrivateKey(privateKey: string): void {
this.privateKey = privateKey;
}
public getPublicKeys(): string[] {
return this.publicKeys;
}
public setPublicKeys(publicKeys: string[]): void {
this.publicKeys = publicKeys;
}
public addPublicKey(publicKey: string): void {
this.publicKeys.push(publicKey);
}
public removePublicKey(publicKey: string): void {
const index = this.publicKeys.indexOf(publicKey);
if (index > -1) {
this.publicKeys.splice(index, 1);
}
}
}

View File

@@ -0,0 +1,60 @@
import Packet from "../packet";
import Stream from "../stream";
/**
* Push Notification actions
* SUBSCRIBE - подписаться на push-уведомления
* UNSUBSCRIBE - отписаться от push-уведомлений
*/
export enum PushNotificationAction {
SUBSCRIBE = 0,
UNSUBSCRIBE = 1,
}
/**
* Push Notification packet
* ID: 0x10
*
* Этот пакет отправляется клиентом для подписки на push-уведомления.
* Отправлять можно только в том случае, если пользователь уже прошел
* рукопожатие и установил соединение.
*/
export class PacketPushNotification extends Packet {
private notificationsToken: string = "";
private action: PushNotificationAction = PushNotificationAction.SUBSCRIBE;
public getPacketId(): number {
return 0x10;
}
public _receive(stream: Stream): void {
this.notificationsToken = stream.readString();
this.action = stream.readInt8();
}
public _send(): Promise<Stream> | Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.notificationsToken);
stream.writeInt8(this.action);
return stream;
}
public getNotificationsToken(): string {
return this.notificationsToken;
}
public setNotificationsToken(notificationsToken: string): void {
this.notificationsToken = notificationsToken;
}
public getAction(): PushNotificationAction {
return this.action;
}
public setAction(action: PushNotificationAction): void {
this.action = action;
}
}

View File

@@ -0,0 +1,52 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketRead extends Packet {
private privateKey : string = "";
private fromPublicKey: string = "";
private toPublicKey: string = "";
public getPacketId(): number {
return 0x07;
}
public _receive(stream: Stream): void {
this.privateKey = stream.readString();
this.fromPublicKey = stream.readString();
this.toPublicKey = stream.readString();
}
public _send(): Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.privateKey);
stream.writeString(this.fromPublicKey);
stream.writeString(this.toPublicKey);
return stream;
}
public setFromPublicKey(fromPublicKey: string): void {
this.fromPublicKey = fromPublicKey;
}
public setToPublicKey(toPublicKey: string): void {
this.toPublicKey = toPublicKey;
}
public getFromPublicKey(): string {
return this.fromPublicKey;
}
public getToPublicKey(): string {
return this.toPublicKey;
}
public setPrivateKey(privateKey: string): void {
this.privateKey = privateKey;
}
public getPrivateKey(): string {
return this.privateKey;
}
}

View File

@@ -0,0 +1,32 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketRequestTransport extends Packet {
private transportServer: string = "";
public getPacketId(): number {
return 0x0F;
}
public _receive(stream: Stream): void {
this.transportServer = stream.readString();
}
public _send(): Promise<Stream> | Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.transportServer);
return stream;
}
public getTransportServer(): string {
return this.transportServer;
}
public setTransportServer(transportServer: string): void {
this.transportServer = transportServer;
}
}

View File

@@ -0,0 +1,65 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketRequestUpdate extends Packet {
private kernelVersion: string = "";
private appVersion: string = "";
private arch: string = "";
private platform: string = "";
public getPacketId(): number {
return 0xA;
}
public _receive(stream: Stream): void {
this.kernelVersion = stream.readString();
this.appVersion = stream.readString();
this.arch = stream.readString();
this.platform = stream.readString();
}
public _send(): Promise<Stream> | Stream {
let stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.kernelVersion);
stream.writeString(this.appVersion);
stream.writeString(this.arch);
stream.writeString(this.platform);
return stream;
}
public setKernelVersion(version: string): void {
this.kernelVersion = version;
}
public getKernelVersion(): string {
return this.kernelVersion;
}
public setAppVersion(version: string): void {
this.appVersion = version;
}
public getAppVersion(): string {
return this.appVersion;
}
public setArch(arch: string): void {
this.arch = arch;
}
public getArch(): string {
return this.arch;
}
public setPlatform(platform: string): void {
this.platform = platform;
}
public getPlatform(): string {
return this.platform;
}
}

View File

@@ -0,0 +1,38 @@
import Packet from "../packet";
import Stream from "../stream";
export enum ResultCode {
SUCCESS = 0,
ERROR = 1,
INVALID = 2,
USERNAME_TAKEN = 3,
}
export class PacketResult extends Packet {
private resultCode: ResultCode = 0;
public getPacketId(): number {
return 0x02;
}
public _receive(stream: Stream): void {
this.resultCode = stream.readInt16();
}
public _send(): Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeInt16(this.resultCode);
return stream;
}
public getResultCode(): ResultCode {
return this.resultCode;
}
public setResultCode(resultCode: ResultCode): void {
this.resultCode = resultCode;
}
}

View File

@@ -0,0 +1,77 @@
import Packet from "../packet";
import Stream from "../stream";
import { OnlineState } from "./packet.onlinestate";
export interface PacketSearchUser {
username: string;
title: string;
publicKey: string;
verified: number;
online: OnlineState;
}
export class PacketSearch extends Packet {
private privateKey : string = "";
private search : string = "";
private users : PacketSearchUser[] = [];
public getPacketId(): number {
return 0x03;
}
public _receive(stream: Stream): void {
this.privateKey = stream.readString();
this.search = stream.readString();
const userCount = stream.readInt16();
for (let i = 0; i < userCount; i++) {
const username = stream.readString();
const title = stream.readString();
const publicKey = stream.readString();
const verified = stream.readInt8();
const online = stream.readInt8();
this.users.push({ username, title, publicKey, online, verified });
}
}
public _send(): Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.privateKey);
stream.writeString(this.search);
stream.writeInt16(this.users.length);
for (const user of this.users) {
stream.writeString(user.username);
stream.writeString(user.title);
stream.writeString(user.publicKey);
stream.writeInt8(user.verified);
stream.writeInt8(user.online);
}
return stream;
}
public getPrivateKey(): string {
return this.privateKey;
}
public setPrivateKey(privateKey: string): void {
this.privateKey = privateKey;
}
public getSearch(): string {
return this.search;
}
public setSearch(search: string): void {
this.search = search;
}
public addUser(searchUser: PacketSearchUser): void {
this.users.push(searchUser);
}
public getUsers(): PacketSearchUser[] {
return this.users;
}
}

View File

@@ -0,0 +1,53 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketTyping extends Packet {
private privateKey: string = "";
private fromPublicKey: string = "";
private toPublicKey: string = "";
public getPacketId(): number {
return 0x0B;
}
public _receive(stream: Stream): void {
this.privateKey = stream.readString();
this.fromPublicKey = stream.readString();
this.toPublicKey = stream.readString();
}
public _send(): Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.privateKey);
stream.writeString(this.fromPublicKey);
stream.writeString(this.toPublicKey);
return stream;
}
public setFromPublicKey(fromPublicKey: string): void {
this.fromPublicKey = fromPublicKey;
}
public setToPublicKey(toPublicKey: string): void {
this.toPublicKey = toPublicKey;
}
public getFromPublicKey(): string {
return this.fromPublicKey;
}
public getToPublicKey(): string {
return this.toPublicKey;
}
public setPrivateKey(privateKey: string): void {
this.privateKey = privateKey;
}
public getPrivateKey(): string {
return this.privateKey;
}
}

View File

@@ -0,0 +1,51 @@
import Packet from "../packet";
import Stream from "../stream";
export class PacketUserInfo extends Packet {
private privateKey : string = "";
private username: string = "";
private title: string = "";
public getPacketId(): number {
return 0x01;
}
public _receive(stream: Stream): void {
this.username = stream.readString();
this.title = stream.readString();
this.privateKey = stream.readString();
}
public _send(): Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.username);
stream.writeString(this.title);
stream.writeString(this.privateKey);
return stream;
}
public getUsername(): string {
return this.username;
}
public setUsername(username: string): void {
this.username = username;
}
public getTitle(): string {
return this.title;
}
public setTitle(title: string): void {
this.title = title;
}
public setPrivateKey(privateKey: string): void {
this.privateKey = privateKey;
}
public getPrivateKey(): string {
return this.privateKey;
}
}