API: Add GetAllOnlineUsers RPC to StatsService for retrieving online users (#5080)

This commit is contained in:
Maxim Plotnikov
2025-12-27 00:07:06 +03:00
committed by GitHub
parent 6738ecf68e
commit ad468e462d
8 changed files with 366 additions and 220 deletions

View File

@@ -161,6 +161,21 @@ func (m *Manager) GetChannel(name string) stats.Channel {
return nil
}
// GetAllOnlineUsers implements stats.Manager.
func (m *Manager) GetAllOnlineUsers() []string {
m.access.Lock()
defer m.access.Unlock()
usersOnline := make([]string, 0, len(m.onlineMap))
for user, onlineMap := range m.onlineMap {
if len(onlineMap.IpTimeMap()) > 0 {
usersOnline = append(usersOnline, user)
}
}
return usersOnline
}
// Start implements common.Runnable.
func (m *Manager) Start() error {
m.access.Lock()