decline & accept devices and protocol connection issues fixed

This commit is contained in:
RoyceDa
2026-01-31 04:55:00 +02:00
parent 22a1fd3a1a
commit a95db0d24b
6 changed files with 129 additions and 9 deletions

View File

@@ -26,6 +26,7 @@ import { PacketGroupLeave } from "./packets/packet.group.leave";
import { PacketGroupBan } from "./packets/packet.group.ban";
import { PacketDeviceNew } from "./packets/packet.device.new";
import { PacketDeviceList } from "./packets/packet.device.list";
import { PacketDeviceResolve } from "./packets/packet.device.resolve";
export default class Protocol extends EventEmitter {
private serverAddress: string;
@@ -122,6 +123,7 @@ export default class Protocol extends EventEmitter {
this._supportedPackets.set(0x15, new PacketGroupLeave());
this._supportedPackets.set(0x16, new PacketGroupBan());
this._supportedPackets.set(0x17, new PacketDeviceList());
this._supportedPackets.set(0x18, new PacketDeviceResolve());
}
private _findWaiters(packetId: number): ((packet: Packet) => void)[] {
@@ -133,6 +135,11 @@ export default class Protocol extends EventEmitter {
public connect() {
this.socket = new WebSocket(this.serverAddress);
/**
* Сбрасываем флаг ручного закрытия соединения
* при подключении
*/
this.isManuallyClosed = false;
this.socket.addEventListener('open', () => {
//this.reconnectTryings = 0;