mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-11-19 05:24:14 +01:00
fix payout calcs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user