diff --git a/server/websocket/internal/logic/ws_statistics.go b/server/websocket/internal/logic/ws_statistics.go index 98d7bbc1..5899a613 100644 --- a/server/websocket/internal/logic/ws_statistics.go +++ b/server/websocket/internal/logic/ws_statistics.go @@ -96,7 +96,11 @@ func ConsumeWebsocketStatData(ctx context.Context) { if ok { //存在就累加 if stat, ok := statData.(mapUserWsStatItem); ok { stat.CurWsConnectCount += data.Value - mapUserWsStat.Store(key, stat) + if stat.CurWsConnectCount == 0 { //为0则移除 + mapUserWsStat.Delete(key) + } else { + mapUserWsStat.Store(key, stat) + } } else { logx.Error("断言mapUserWsStatItem错误") }