Commit a9184fd0 authored by Robert Knight's avatar Robert Knight

Remove unused code path in `connect` helper

Given the way the `Socket` helper currently works, the `connect` helper
cannot be called while there is already a connection. `connect` is
called once during the initial `Socket` constructor and subsequently to
initiate an automatic reconnect in the event of an abnormal
disconnection. In both cases there is no existing connection.
parent ac3de0d9
...@@ -94,22 +94,13 @@ export class Socket extends TinyEmitter { ...@@ -94,22 +94,13 @@ export class Socket extends TinyEmitter {
// ...otherwise reconnect the websocket after a short delay. // ...otherwise reconnect the websocket after a short delay.
let delay = RECONNECT_MIN_DELAY; let delay = RECONNECT_MIN_DELAY;
delay += Math.floor(Math.random() * delay); delay += Math.floor(Math.random() * delay);
setTimeout(() => { setTimeout(reconnect, delay);
operation = null;
reconnect();
}, delay);
}; };
/** /**
* Connect the WebSocket. * Connect the WebSocket.
*
* If a connection attempt is already in progress, do nothing.
*/ */
const connect = () => { const connect = () => {
if (operation) {
return;
}
operation = /** @type {RetryOperation} */ ( operation = /** @type {RetryOperation} */ (
retry.operation({ retry.operation({
minTimeout: RECONNECT_MIN_DELAY * 2, minTimeout: RECONNECT_MIN_DELAY * 2,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment