Skip to content

Commit

Permalink
fixing for connections in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dolled-possum committed Jan 14, 2025
1 parent 93f829a commit e7158ba
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,13 @@ wss.on('connection', (clientSocket, req, remoteSocket) => {
const node = proxyUser.substring(0, lastHyphenIndex);
const shortcode = proxyUser.substring(lastHyphenIndex + 1);
const userConnections = cache.get(`${shortcode}-userConnections`);
userConnections.set(node, userConnections.get(node) + 1);
tsLog(`node: ${node} updated userConnections entry to ${userConnections.get(node)}`);
if (userConnections.has(node)) {
userConnections.set(node, userConnections.get(node) + 1);
tsLog(`node: ${node} updated userConnections entry to ${userConnections.get(node)}`);
} else {
userConnections.set(node, 1);
tsLog(`Added new ${shortcode}-userConnections entry for node: ${node}`);
}
cache.set(`${shortcode}-userConnections`, userConnections);
}

Expand All @@ -129,11 +134,16 @@ wss.on('connection', (clientSocket, req, remoteSocket) => {
const node = proxyUser.substring(0, lastHyphenIndex);
const shortcode = proxyUser.substring(lastHyphenIndex + 1);
const userConnections = cache.get(`${shortcode}-userConnections`);
userConnections.set(node, userConnections.get(node) + 1);
tsLog(`node: ${node} updated userConnections entry to ${userConnections.get(node)}`);
if (userConnections.has(node)) {
userConnections.set(node, userConnections.get(node) + 1);
tsLog(`node: ${node} updated userConnections entry to ${userConnections.get(node)}`);
} else {
userConnections.set(node, 1);
tsLog(`Added new ${shortcode}-userConnections entry for node: ${node}`);
}
cache.set(`${shortcode}-userConnections`, userConnections);
}

});

// Close events
Expand Down

0 comments on commit e7158ba

Please sign in to comment.