add error notice on online counter broadcast

This commit is contained in:
HF 2022-07-02 13:24:09 +02:00
parent 214daa6382
commit eee3d6a7ec
2 changed files with 36 additions and 28 deletions

View File

@ -207,11 +207,15 @@ class SocketClient extends EventEmitter {
this.emit('pixelUpdate', PixelUpdate.hydrate(data));
break;
case PixelReturn.OP_CODE:
/*
* using online counter and pxlReturn as sign-of-life ping
*/
this.timeLastPing = Date.now();
this.emit('pixelReturn', PixelReturn.hydrate(data));
break;
case OnlineCounter.OP_CODE:
/*
* using online counter as sign-of-life ping
* using online counter and pxlReturn as sign-of-life ping
*/
this.timeLastPing = Date.now();
this.emit('onlineCounter', OnlineCounter.hydrate(data));

View File

@ -361,6 +361,7 @@ class SocketServer {
}
onlineCounterBroadcast() {
try {
const online = {};
online.total = ipCounter.amount() || 0;
const ipsPerCanvas = {};
@ -391,6 +392,9 @@ class SocketServer {
client = it.next();
}
socketEvents.broadcastOnlineCounter(online);
} catch (err) {
logger.error(`WebSocket online broadcast error: ${err.message}`);
}
}
async onTextMessage(text, ws) {