decline & accept devices and protocol connection issues fixed
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import Packet from "../packet";
|
||||
import Stream from "../stream";
|
||||
|
||||
/**
|
||||
* Решение по устройству при верификации
|
||||
* Отклонить или принять
|
||||
*/
|
||||
export enum Solution {
|
||||
DECLINE,
|
||||
ACCEPT
|
||||
}
|
||||
|
||||
/**
|
||||
* Отправляется клиентом при решении по устройству
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user