mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 23:24:52 +09:00
Fix WebSocketClientConnector lifecycle events
Fix drop being repeatedly emitted while reconnecting and close not being emitted on connection timeout.
This commit is contained in:
1 parent
c87538ca58
commit
04ee3d3f96
1 file changed
+8
-11
+8
-11
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user