Skip to content

Commit

Permalink
Cleanup some timeout variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed Aug 17, 2024
1 parent d3d91ed commit d9053f2
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ class TuyaDevice extends EventEmitter {
// Check for response
const now = new Date();

clearTimeout(this._pingPongTimeout);
this._pingPongTimeout = setTimeout(() => {
if (this._lastPingAt < now) {
this.disconnect();
Expand Down Expand Up @@ -720,9 +721,6 @@ class TuyaDevice extends EventEmitter {
}

_packetHandler(packet) {
// Response was received, so stop waiting
clearTimeout(this._sendTimeout);

// Protocol 3.4, 3.5 - Response to Msg 0x03
if (packet.commandByte === CommandType.SESS_KEY_NEG_RES) {
if (!this.connectPromise) {
Expand Down Expand Up @@ -923,9 +921,6 @@ class TuyaDevice extends EventEmitter {
this.device.parser.cipher.setSessionKey(null);

// Clear timeouts
clearTimeout(this._sendTimeout);
clearTimeout(this._connectTimeout);
clearTimeout(this._responseTimeout);
clearInterval(this._pingPongInterval);
clearTimeout(this._pingPongTimeout);

Expand Down

0 comments on commit d9053f2

Please sign in to comment.