aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/api/api/Services/ChatHub.cs6
1 files changed, 4 insertions, 2 deletions
diff --git a/backend/api/api/Services/ChatHub.cs b/backend/api/api/Services/ChatHub.cs
index 72febce1..7b4e94dd 100644
--- a/backend/api/api/Services/ChatHub.cs
+++ b/backend/api/api/Services/ChatHub.cs
@@ -31,8 +31,10 @@ namespace api.Services
}
public override async Task OnDisconnectedAsync(Exception? exception)
{
- string id = Users.FirstOrDefault(u => u.Value == Context.ConnectionId).Key;
- Users.Remove(id);
+ var user = Users.Values.Contains(Context.ConnectionId);
+ if (user==false)
+ return;
+ Users.Remove(Users.FirstOrDefault(u => u.Value == Context.ConnectionId).Key);
}
public async Task SendDirect(string id,string message)
{