diff --git a/p42wssGateway.js b/p42wssGateway.js index 0caaa74..319122d 100644 --- a/p42wssGateway.js +++ b/p42wssGateway.js @@ -203,12 +203,13 @@ cfgh.fetchConfig().then( async wssGatewayConfig => { // ws.send(`You visited ${ws.session.views} times`) // }) - HTTPserver.listen(wssGatewayConfig.server.listenPort, () => { - console.log(`WS${wssGatewayConfig.server.unsecure ? '': 'S'} server created for ${wssGatewayConfig.server.listenHost}:${wssGatewayConfig.server.listenPort}`) - }) - - startAllRedis(wssGatewayConfig).then((allRediscnx) => { + startAllRedis(wssGatewayConfig) + .then((allRediscnx) => { + console.log('All edis OK') const wssSrv = new wssServer(cfgh, WSSServer, allRediscnx, debug); + HTTPserver.listen(wssGatewayConfig.server.listenPort, () => { + console.log(`WS${wssGatewayConfig.server.unsecure ? '': 'S'} server created for ${wssGatewayConfig.server.listenHost}:${wssGatewayConfig.server.listenPort}`) + }) }); diff --git a/wssConnexion.js b/wssConnexion.js index 076e260..aaac176 100644 --- a/wssConnexion.js +++ b/wssConnexion.js @@ -31,10 +31,15 @@ export class WssConnexion { } welcome(){ - clearTimeout(this.challengeTimeout) - this.challengeTimeout = null + // clearTimeout(this.challengeTimeout) + // this.challengeTimeout = null this.cnxState = 'CONNECTED' - if(this.debug) console.log(`Welcome to UUID ${this.uuid}`) + this.send(JSON.stringify({ + 'action': 'WELCOME', + 'cnxId': this.uuid, + 'serverTime': Date.now(), + })); + if(this.debug) console.log(`Welcome to UUID ${this.uuid}, server time: ${performance.now()}`) } startKeepAlive() { diff --git a/wssServer.js b/wssServer.js index 3888165..2d3f7c6 100644 --- a/wssServer.js +++ b/wssServer.js @@ -29,6 +29,7 @@ export class wssServer { } newWSSConnexion(socket, req) { + console.log('newWSSConnexion') var uuid = crypto.randomUUID(); if(socket.session && socket.session.authenticated && socket.session.userInfos && socket.session.userInfos.identity && socket.session.userInfos.identity.username){ var wssCnx = new WssConnexion({ @@ -48,12 +49,13 @@ export class wssServer { this.Users2uuids[wssCnx.userId].add(uuid); this.OnlineUsers.add(wssCnx.userId); this.allRediscnx.forEach(cnx => { cnx.wssConnections[uuid] = wssCnx }) - this.postLoginActions(wssCnx) + setImmediate(() => this.postLoginActions(wssCnx)) } else socket.close() } postLoginActions(wssCnx) { + wssCnx.welcome() wssCnx.startKeepAlive() wssCnx.subscribeMandatoryChans() wssCnx.action_SUBLST('SUBLST', null, '')