From 36e9acd7aa945a412486521b7a079e8e39ea153a Mon Sep 17 00:00:00 2001 From: Marcus Date: Thu, 1 Apr 2021 01:22:48 -0400 Subject: [PATCH] always start server... --- lib/node.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/node.js b/lib/node.js index 17aeaa4..14ec16b 100644 --- a/lib/node.js +++ b/lib/node.js @@ -25,7 +25,20 @@ class Node extends EventEmitter { // log.info('secured connection from ' + socket.remoteAddress); // this.clients.push(socket); // }); - this.readyPromise = this.negotiatePort(); + this.readyPromise = this.negotiatePort().then(this.startServer.bind(this)); + } + + startServer() { + + console.log('creating server on port ' + this.port); + + stp.createServer({ + identity: this.identity, + port: this.port + }, (connection) => { + console.log('incomming connection...'); + console.dir(connection); + }) } async negotiatePort() { @@ -55,15 +68,7 @@ class Node extends EventEmitter { } } - console.log('creating server on port ' + this.port); - stp.createServer({ - identity: this.identity, - port: this.port - }, (connection) => { - console.log('incomming connection...'); - console.dir(connection); - }) // console.log(mappings, this.hash); }