feat(dashboard): add online count for events
Show real-time count of users currently in each event chat room. - Backend: Export getEventsOnlineCounts from socket module - Dashboard API: Include onlineCount for each active event - Frontend: Display online count with animated green dot indicator
This commit is contained in:
@@ -461,4 +461,21 @@ function initializeSocket(httpServer) {
|
||||
return io;
|
||||
}
|
||||
|
||||
module.exports = { initializeSocket, getIO };
|
||||
// Get count of online users for a specific event
|
||||
function getEventOnlineCount(eventId) {
|
||||
if (!activeUsers.has(eventId)) {
|
||||
return 0;
|
||||
}
|
||||
return activeUsers.get(eventId).size;
|
||||
}
|
||||
|
||||
// Get online counts for multiple events
|
||||
function getEventsOnlineCounts(eventIds) {
|
||||
const counts = {};
|
||||
for (const eventId of eventIds) {
|
||||
counts[eventId] = getEventOnlineCount(eventId);
|
||||
}
|
||||
return counts;
|
||||
}
|
||||
|
||||
module.exports = { initializeSocket, getIO, getEventOnlineCount, getEventsOnlineCounts };
|
||||
|
||||
Reference in New Issue
Block a user