From 684f1a641dfd2b12c9a9abdcf84826bdeebed4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Wed, 23 Aug 2017 01:19:50 -0400 Subject: [PATCH] Make sure server is running before loading users --- src/server.js | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/server.js b/src/server.js index d8c4626b..6eb6ee7d 100644 --- a/src/server.js +++ b/src/server.js @@ -89,28 +89,32 @@ module.exports = function() { }, () => { const protocol = config.https.enable ? "https" : "http"; var address = server.address(); - log.info(`Available on ${colors.green(protocol + "://" + address.address + ":" + address.port + "/")} \ -in ${config.public ? "public" : "private"} mode`); - }); - var sockets = io(server, { - serveClient: false, - transports: config.transports - }); + log.info( + "Available at " + + colors.green(`${protocol}://${address.address}:${address.port}/`) + + ` in ${colors.bold(config.public ? "public" : "private")} mode` + ); - sockets.on("connect", function(socket) { - if (config.public) { - performAuthentication.call(socket, {}); - } else { - socket.emit("auth", {success: true}); - socket.on("auth", performAuthentication); - } - }); + const sockets = io(server, { + serveClient: false, + transports: config.transports + }); - manager = new ClientManager(); + sockets.on("connect", (socket) => { + if (config.public) { + performAuthentication.call(socket, {}); + } else { + socket.emit("auth", {success: true}); + socket.on("auth", performAuthentication); + } + }); - new Identification((identHandler) => { - manager.init(identHandler, sockets); + manager = new ClientManager(); + + new Identification((identHandler) => { + manager.init(identHandler, sockets); + }); }); };