Fix WebSocketClientConnector lifecycle events

Fix drop being repeatedly emitted while reconnecting and close not being
emitted on connection timeout.
This commit is contained in:
Hornwitser committed 2020-05-09 16:28:07 +02:00
1 parent c87538ca58
commit 04ee3d3f96
1 file changed
+8 -11
+8 -11
View File
@@ -260,11 +260,8 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
this._lastReceivedSeq = null;
this._sessionToken = null;
this._sendBuffer.length = 0;
if (this._connected) {
this._connected = false;
this.emit("close");
}
this.emit("invalidate");
this._connected = false;
this.emit("close");
return;
}
@@ -290,16 +287,16 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
this._sessionToken = null;
this._sendBuffer.length = 0;
this._state = "new";
if (this._connected) {
this._connected = false;
this.emit("close");
}
this._connected = false;
this.emit("close");
} else {
this._state = "handshake";
this.reconnect();
this.emit("drop");
if (this._connected) {
this._connected = false;
this.emit("drop");
}
}
this.stopHeartbeat();