send time in messages, and also make sure that there are no phantom users (it will happen when a user's connection is suddenly stopped, or their ip changes)

This commit is contained in:
2026-07-21 20:55:03 +02:00
parent 820e281ac5
commit b670a74bb3
4 changed files with 37 additions and 75 deletions
+5 -5
View File
@@ -280,19 +280,19 @@ function resolveDataBuffer(data) {
if (receivedData.length) dataHandler.handleData(wss, receivedData, rdsWss);
}
function kickClient(ipAddress) {
// Find the entry in connectedClients associated with the provided IP address
const targetClient = storage.connectedUsers.find(client => client.ip === ipAddress);
if (targetClient && targetClient.instance) {
// Send a termination message to the client
targetClient.instance.send('KICK');
// Close the WebSocket connection after a short delay to allow the client to receive the message
setTimeout(() => {
targetClient.instance.close();
const index = storage.connectedUsers.indexOf(targetClient);
if (index !== -1) storage.connectedUsers.splice(index, 1);
consoleCmd.logInfo(`Web client kicked (${ipAddress})`);
}, 500);
}, 750);
} else consoleCmd.logInfo(`Kicking client ${ipAddress} failed. No suitable client found.`);
}