fix(chat): 优化后台限流与 SSE 日志

This commit is contained in:
yml2213
2026-08-25 16:20:58 +08:00
parent 417f7398e4
commit 8f6356a3d7
11 changed files with 344 additions and 47 deletions
+13
View File
@@ -190,3 +190,16 @@ func (h *Hub) OnlineCount() int {
}
return count
}
// OnlineCountByType 返回当前进程内指定主体类型的 SSE 连接数。
func (h *Hub) OnlineCountByType(pType string) int {
h.mu.RLock()
defer h.mu.RUnlock()
count := 0
for key, clients := range h.clients {
if key.Type == pType {
count += len(clients)
}
}
return count
}