diff options
| author | David Skoland <davidskoland@gmail.com> | 2023-11-22 21:10:10 +0100 |
|---|---|---|
| committer | David Skoland <davidskoland@gmail.com> | 2023-11-22 21:10:10 +0100 |
| commit | b0f6ebd5a1a7391b5a9f0165cab01f23da3461da (patch) | |
| tree | 35370cdf9135728d72bdba8534b95979580475db /webAO | |
| parent | 060409093da1d3392c0e165b043401baa3fb5d6b (diff) | |
Set timeout to connecting to server to 5 seconds
Diffstat (limited to 'webAO')
| -rw-r--r-- | webAO/client.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/webAO/client.ts b/webAO/client.ts index 6341ab2..fde7f15 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -157,6 +157,14 @@ class Client extends EventEmitter { this.serv.addEventListener("close", this.emit.bind(this, "close")); this.serv.addEventListener("message", this.emit.bind(this, "message")); this.serv.addEventListener("error", this.emit.bind(this, "error")); + + // If the client is still not connected 5 seconds after attempting to join + // It's fair to assume that the server is not reachable + setTimeout(() => { + if (this.state === clientState.NotConnected) { + this.serv.close(); + } + }, 5000); } else { this.joinServer(); } |
