aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/Main.hx
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Main.hx')
-rw-r--r--src/server/Main.hx15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/server/Main.hx b/src/server/Main.hx
index 6c7753c..ee4d478 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -101,6 +101,20 @@ class Main {
server.listen(port);
wss = new WSServer({server: server});
wss.on("connection", onConnect);
+
+ new Timer(25000).run = () -> {
+ for (client in clients) {
+ if (client.isAlive) {
+ client.isAlive = false;
+ client.ws.ping();
+ continue;
+ }
+ client.ws.terminate();
+ onMessage(client, {
+ type: Disconnected
+ }, true);
+ }
+ };
}
public function exit():Void {
@@ -276,6 +290,7 @@ class Main {
final client = new Client(ws, req, id, name, 0);
client.isAdmin = isAdmin;
clients.push(client);
+ ws.on("pong", () -> client.isAlive = true);
onMessage(client, {
type: Connected
}, true);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage