cleanup, welcome with proper server time

This commit is contained in:
STEINNI
2026-06-26 21:51:43 +00:00
parent a868caf8c9
commit b551f473b4
3 changed files with 17 additions and 9 deletions
+6 -5
View File
@@ -203,12 +203,13 @@ cfgh.fetchConfig().then( async wssGatewayConfig => {
// ws.send(`You visited ${ws.session.views} times`) // ws.send(`You visited ${ws.session.views} times`)
// }) // })
HTTPserver.listen(wssGatewayConfig.server.listenPort, () => { startAllRedis(wssGatewayConfig)
console.log(`WS${wssGatewayConfig.server.unsecure ? '': 'S'} server created for ${wssGatewayConfig.server.listenHost}:${wssGatewayConfig.server.listenPort}`) .then((allRediscnx) => {
}) console.log('All edis OK')
startAllRedis(wssGatewayConfig).then((allRediscnx) => {
const wssSrv = new wssServer(cfgh, WSSServer, allRediscnx, debug); 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}`)
})
}); });
+8 -3
View File
@@ -31,10 +31,15 @@ export class WssConnexion {
} }
welcome(){ welcome(){
clearTimeout(this.challengeTimeout) // clearTimeout(this.challengeTimeout)
this.challengeTimeout = null // this.challengeTimeout = null
this.cnxState = 'CONNECTED' 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() { startKeepAlive() {
+3 -1
View File
@@ -29,6 +29,7 @@ export class wssServer {
} }
newWSSConnexion(socket, req) { newWSSConnexion(socket, req) {
console.log('newWSSConnexion')
var uuid = crypto.randomUUID(); var uuid = crypto.randomUUID();
if(socket.session && socket.session.authenticated && socket.session.userInfos && socket.session.userInfos.identity && socket.session.userInfos.identity.username){ if(socket.session && socket.session.authenticated && socket.session.userInfos && socket.session.userInfos.identity && socket.session.userInfos.identity.username){
var wssCnx = new WssConnexion({ var wssCnx = new WssConnexion({
@@ -48,12 +49,13 @@ export class wssServer {
this.Users2uuids[wssCnx.userId].add(uuid); this.Users2uuids[wssCnx.userId].add(uuid);
this.OnlineUsers.add(wssCnx.userId); this.OnlineUsers.add(wssCnx.userId);
this.allRediscnx.forEach(cnx => { cnx.wssConnections[uuid] = wssCnx }) this.allRediscnx.forEach(cnx => { cnx.wssConnections[uuid] = wssCnx })
this.postLoginActions(wssCnx) setImmediate(() => this.postLoginActions(wssCnx))
} else socket.close() } else socket.close()
} }
postLoginActions(wssCnx) { postLoginActions(wssCnx) {
wssCnx.welcome()
wssCnx.startKeepAlive() wssCnx.startKeepAlive()
wssCnx.subscribeMandatoryChans() wssCnx.subscribeMandatoryChans()
wssCnx.action_SUBLST('SUBLST', null, '') wssCnx.action_SUBLST('SUBLST', null, '')