switch interval to timeout

This commit is contained in:
Elijah 2023-12-10 16:03:18 -05:00
parent 49728dc841
commit 1adac4f982

View file

@ -99,8 +99,8 @@ export default class VM {
return;
}
var msg = msgpack.decode(this.#currentChunk!) as protocol.ProtocolMessage;
if (this.#nopTimeout) clearInterval(this.#nopTimeout);
this.#nopTimeout = setInterval(() => this.#nopTimeoutFunc(), 5000);
if (this.#nopTimeout) clearTimeout(this.#nopTimeout);
this.#nopTimeout = setTimeout(() => this.#nopTimeoutFunc(), 5000);
if (!this.isConnectedToVM) {
log("INFO", `Got connection to VM at ${this.#id}`);
if (this.#messageQueue.size > 0) this.messageQueueLoop();
@ -120,9 +120,10 @@ export default class VM {
Operation: protocol.ProtocolOperation.NOP
});
this.#noNop = true;
setTimeout(() => this.#nopTimeoutFunc(), 5000);
} else {
this.isConnectedToVM = false;
clearInterval(this.#nopTimeout!);
clearTimeout(this.#nopTimeout!);
log("INFO", `Connection to VM at ${this.#id} timed out`);
}
}