public override async Task OnConnectedAsync() { UserDto currentUser = GetUserOrAbort(); await _subscriptionService.BindConnectionToUserAsync(currentUser.Id, Context.ConnectionId); var preferences = await _subscriptionService.GetMyPreferencesAsync(currentUser.Id); var welcomeNotifications = await LoadWelcomeMessages(preferences, currentUser.Id); foreach (var welcomeNotification in welcomeNotifications) { await Clients.Client(Context.ConnectionId).SendAsync("WelcomeNotifications", welcomeNotification); _logger.LogInformation( $"Sent historic notification: '{welcomeNotification.Id}' to '{currentUser.Nickname}' of id: '{currentUser.Id}'."); } if (preferences.DoNotNotifyAnyoneAboutMyActivity == false) { var userConnected = NotificationDto.Factory.UserConnected(currentUser); await Clients.Others.SendAsync("connected", userConnected); } await base.OnConnectedAsync(); }