diff options
author | marzavec <admin@marzavec.com> | 2019-11-07 08:35:23 +0100 |
---|---|---|
committer | marzavec <admin@marzavec.com> | 2019-11-07 08:35:23 +0100 |
commit | f28e65ab8035682372edbe1c11d9ca2581e0a2e6 (patch) | |
tree | a75c9b682ca245baa3f01df5ea704ba95205cef3 /server/src/commands/core/stats.js | |
parent | Merge pull request #79 from 0x17de/feature-emote-trip (diff) | |
download | hackchat-f28e65ab8035682372edbe1c11d9ca2581e0a2e6.tar.gz hackchat-f28e65ab8035682372edbe1c11d9ca2581e0a2e6.zip |
Syntax update and formatting tweaks
Diffstat (limited to '')
-rw-r--r-- | server/src/commands/core/stats.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/server/src/commands/core/stats.js b/server/src/commands/core/stats.js index ff4b1ef..8badd5b 100644 --- a/server/src/commands/core/stats.js +++ b/server/src/commands/core/stats.js @@ -3,19 +3,20 @@ */ // module main -exports.run = async (core, server, socket, data) => { +export async function run(core, server, socket) { // gather connection and channel count let ips = {}; let channels = {}; - for (let client of server.clients) { + // for (const client of server.clients) { + this.clients.forEach((client) => { if (client.channel) { channels[client.channel] = true; - ips[client.remoteAddress] = true; + ips[client.address] = true; } - } + }); - let uniqueClientCount = Object.keys(ips).length; - let uniqueChannels = Object.keys(channels).length; + const uniqueClientCount = Object.keys(ips).length; + const uniqueChannels = Object.keys(channels).length; ips = null; channels = null; @@ -23,17 +24,16 @@ exports.run = async (core, server, socket, data) => { // dispatch info server.reply({ cmd: 'info', - text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels` + text: `${uniqueClientCount} unique IPs in ${uniqueChannels} channels`, }, socket); // stats are fun core.stats.increment('stats-requested'); -}; +} -// module meta -exports.info = { +export const info = { name: 'stats', description: 'Sends back legacy server stats to the calling client', usage: ` - API: { cmd: 'stats' }` + API: { cmd: 'stats' }`, }; |