fix payout calcs

This commit is contained in:
jwinterm
2025-12-24 20:03:26 -05:00
parent 0ff95d3142
commit 2c781ec043
4 changed files with 49 additions and 3 deletions
+13
View File
@@ -8,10 +8,23 @@ class BroadcastManager {
constructor(io) {
this.io = io;
this._lastBroadcastBlock = null;
this._lastUserCount = -1;
}
// ====== GLOBAL BROADCASTS (All Clients) ======
/**
* Broadcast connected user count to all clients
*/
broadcastUserCount() {
const count = this.io.engine ? this.io.engine.clientsCount : 0;
// Only broadcast if count changed to avoid spam
if (count !== this._lastUserCount) {
this._lastUserCount = count;
this.io.emit('user_count', { count });
}
}
/**
* Broadcast block height to all connected clients
* @param {number} blockHeight - Current block height
+6
View File
@@ -64,6 +64,9 @@ class ConnectionHandler {
// Send current state
this._sendConnectionStatus(socket);
// Broadcast updated user count to all clients
this.broadcastManager.broadcastUserCount();
return { sessionInfo, memUser };
} catch (error) {
@@ -112,6 +115,9 @@ class ConnectionHandler {
// Clean up user records
user.removeUser(socket.client.id);
// Broadcast updated user count to all clients
this.broadcastManager.broadcastUserCount();
// Call additional cleanup if provided
if (additionalCleanup && typeof additionalCleanup === 'function') {
additionalCleanup(socket);