diff --git a/index.ts b/index.ts index a319dcb..e04da04 100644 --- a/index.ts +++ b/index.ts @@ -118,13 +118,16 @@ if (process.argv[2] === "server") { process.exit(1); } const config:IClientConfig = JSON.parse(readFileSync("./config/client-config.json").toString()); + let CLIENT_ID = 0; const server = createServer((socket) => { let authed = false; let queuedMessages = new Array(); let txBytes = 0; let rxBytes = 0; + const thisClientId = CLIENT_ID++; + console.log(`[LOCAL CLIENT ${thisClientId}] New Connection`); const txrxInterval = setInterval(() => { - console.log(`TX: ${(txBytes / 1024).toFixed(2)}KB/s | RX: ${(rxBytes / 1024).toFixed(2)}KB/s`); + console.log(`[LOCAL CLIENT ${thisClientId}] TX: ${(txBytes / 1024).toFixed(2)}KB/s | RX: ${(rxBytes / 1024).toFixed(2)}KB/s`); txBytes = rxBytes = 0; }, 1000); @@ -171,6 +174,7 @@ if (process.argv[2] === "server") { function clientCloseOrError() { socket.end(); clearInterval(txrxInterval); + console.log(`[LOCAL CLIENT ${thisClientId}] Remote server terminated the connection.`); } client.on("close", clientCloseOrError); client.on("error", clientCloseOrError); @@ -188,6 +192,7 @@ if (process.argv[2] === "server") { function serverCloseOrError() { client.close(); clearInterval(txrxInterval); + console.log(`[LOCAL CLIENT ${thisClientId}] Disconnected`); } socket.on("close", serverCloseOrError); socket.on("error", serverCloseOrError);