forked from ppfun/pixelplanet
add error notice on online counter broadcast
This commit is contained in:
parent
214daa6382
commit
eee3d6a7ec
|
@ -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));
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user