Merge branch 'production'

This commit is contained in:
HF 2021-03-18 21:32:14 +01:00
commit 624a1811bc
2 changed files with 6 additions and 2 deletions

View File

@ -87,7 +87,7 @@ class SocketServer extends WebSocketEvents {
cheapDetector(user.ip);
ws.send(OnlineCounter.dehydrate({
online: this.wss.clients.size || 0,
online: ipCounter.amount() || 0,
}));
const ip = getIPFromRequest(req);
@ -282,7 +282,7 @@ class SocketServer extends WebSocketEvents {
}
onlineCounterBroadcast() {
const online = this.wss.clients.size || 0;
const online = ipCounter.amount() || 0;
webSockets.broadcastOnlineCounter(online);
}

View File

@ -11,6 +11,10 @@ export default class Counter<T> {
this.map = new Map();
}
amount(): number {
return this.map.size;
}
get(item: T): number {
const count = this.map.get(item) || 0;
return count;