From 21d0d43edc387dac8d4fc9a788a6548a80cda32a Mon Sep 17 00:00:00 2001 From: mikiher Date: Wed, 27 Dec 2023 15:33:33 +0200 Subject: [PATCH] Add SocketAuthority.close() --- server/Server.js | 2 +- server/SocketAuthority.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/Server.js b/server/Server.js index 3de8ff7f..bb683826 100644 --- a/server/Server.js +++ b/server/Server.js @@ -401,7 +401,7 @@ class Server { Logger.info('Watcher Closed') return new Promise((resolve) => { - this.server.close((err) => { + SocketAuthority.close((err) => { if (err) { Logger.error('Failed to close server', err) } else { diff --git a/server/SocketAuthority.js b/server/SocketAuthority.js index da17f5df..b4698ef9 100644 --- a/server/SocketAuthority.js +++ b/server/SocketAuthority.js @@ -73,6 +73,15 @@ class SocketAuthority { } } + close(callback) { + Logger.info('[SocketAuthority] Shutting down') + // This will close all open socket connections, and also close the underlying http server + if (this.io) + this.io.close(callback) + else + callback() + } + initialize(Server) { this.Server = Server