fix(chat): 优化后台限流与 SSE 日志
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user