cleanup, welcome with proper server time
This commit is contained in:
+4
-3
@@ -203,12 +203,13 @@ cfgh.fetchConfig().then( async wssGatewayConfig => {
|
||||
// ws.send(`You visited ${ws.session.views} times`)
|
||||
// })
|
||||
|
||||
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}`)
|
||||
})
|
||||
|
||||
startAllRedis(wssGatewayConfig).then((allRediscnx) => {
|
||||
const wssSrv = new wssServer(cfgh, WSSServer, allRediscnx, debug);
|
||||
});
|
||||
|
||||
|
||||
|
||||
+8
-3
@@ -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() {
|
||||
|
||||
+3
-1
@@ -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, '')
|
||||
|
||||
Reference in New Issue
Block a user