mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-18 06:41:27 +02:00
fix user count broadcast timing
This commit is contained in:
@@ -17,7 +17,14 @@ class BroadcastManager {
|
||||
* Broadcast connected user count to all clients
|
||||
*/
|
||||
broadcastUserCount() {
|
||||
const count = this.io.engine ? this.io.engine.clientsCount : 0;
|
||||
// Try multiple ways to get the count
|
||||
let count = 0;
|
||||
if (this.io.sockets && this.io.sockets.sockets) {
|
||||
count = this.io.sockets.sockets.size || 0;
|
||||
} else if (this.io.engine) {
|
||||
count = this.io.engine.clientsCount || 0;
|
||||
}
|
||||
|
||||
// Only broadcast if count changed to avoid spam
|
||||
if (count !== this._lastUserCount) {
|
||||
this._lastUserCount = count;
|
||||
|
||||
@@ -64,8 +64,8 @@ class ConnectionHandler {
|
||||
// Send current state
|
||||
this._sendConnectionStatus(socket);
|
||||
|
||||
// Broadcast updated user count to all clients
|
||||
this.broadcastManager.broadcastUserCount();
|
||||
// Broadcast updated user count to all clients (small delay to ensure socket is registered)
|
||||
setTimeout(() => this.broadcastManager.broadcastUserCount(), 100);
|
||||
|
||||
return { sessionInfo, memUser };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user