From 8c026be22dc857aa31137808e20ace76d02c479f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 31 Oct 2023 15:08:00 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/ws_statistics.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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错误") }