Files
desktop/app/providers/ProtocolProvider/protocol/packets/packet.device.resolve.ts

54 lines
1.2 KiB
TypeScript

import Packet from "../packet";
import Stream from "../stream";
/**
* Решение по устройству при верификации
* Отклонить или принять
*/
export enum Solution {
ACCEPT,
DECLINE
}
/**
* Отправляется клиентом при решении по устройству
*/
export class PacketDeviceResolve extends Packet {
private deviceId: string = "";
private solution: Solution = Solution.DECLINE;
public getPacketId(): number {
return 0x18;
}
public _receive(stream: Stream): void {
this.deviceId = stream.readString();
this.solution = stream.readInt8();
}
public _send(): Promise<Stream> | Stream {
const stream = new Stream();
stream.writeInt16(this.getPacketId());
stream.writeString(this.deviceId);
stream.writeInt8(this.solution);
return stream;
}
public getDeviceId(): string {
return this.deviceId;
}
public getSolution(): Solution {
return this.solution;
}
public setDeviceId(deviceId: string): void {
this.deviceId = deviceId;
}
public setSolution(solution: Solution): void {
this.solution = solution;
}
}