aboutsummaryrefslogtreecommitdiff
path: root/webAO/client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'webAO/client.ts')
-rw-r--r--webAO/client.ts8
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();
}