public override async Task OnConnectedAsync() { var userId = Guid.Parse(Context.User.Claims.Single(x => x.Type == "UserId").Value); var connectionId = Context.ConnectionId; _onlineUsers.MapChatHubConnection(userId, connectionId); if (_onlineUsers.CountChatHubConnections(userId) == 1) { await Clients.All.SendAsync("ChatUserConnected", _onlineUsers.GetUser(userId)); } await base.OnConnectedAsync(); }