private void OnConversationAdded(object sender, EntityChangedEventArgs <Conversation> e) { var conversationNotification = new EntityNotification <Conversation>(e.Entity, NotificationType.Create); IEnumerable <int> userIds = participationRepository.GetParticipationsByConversationId(e.Entity.Id).Select(participation => participation.UserId); ClientManager.SendMessageToClients(conversationNotification, userIds); }
private void OnUserTypingChanged(Participation participation) { List <Participation> participationsForConversation = participationRepository.GetParticipationsByConversationId(participation.ConversationId); List <int> usersInConversation = participationsForConversation.Select(x => x.UserId).ToList(); var userTypingNotification = new EntityNotification <UserTyping>(participation.UserTyping, NotificationType.Update); ClientManager.SendMessageToClients(userTypingNotification, usersInConversation); }
private void SendConversationNotificationToParticipants(Conversation conversation, int newParticipantUserId, IEnumerable <Participation> otherParticipants) { if (conversation != null) { ClientManager.SendMessageToClient(new EntityNotification <Conversation>(conversation, NotificationType.Create), newParticipantUserId); IEnumerable <int> currentConversationParticipantUserIds = otherParticipants.Select(participant => participant.UserId); ClientManager.SendMessageToClients(new EntityNotification <Conversation>(conversation, NotificationType.Update), currentConversationParticipantUserIds); } }
private void OnContributionAdded(IContribution contribution) { var contributionNotification = new EntityNotification <IContribution>(contribution, NotificationType.Create); List <Participation> participationsByConversationId = participationRepository.GetParticipationsByConversationId(contribution.ConversationId); IEnumerable <User> participantUsers = participationsByConversationId.Select(participant => userRepository.FindEntityById(participant.UserId)); IEnumerable <int> connectedUserIds = participantUsers.Where(user => user.ConnectionStatus.UserConnectionStatus == ConnectionStatus.Status.Connected).Select(user => user.Id); ClientManager.SendMessageToClients(contributionNotification, connectedUserIds); }
private void OnParticipationAdded(object sender, EntityChangedEventArgs <Participation> e) { Participation participation = e.Entity; List <Participation> conversationParticipants = participationRepository.GetParticipationsByConversationId(participation.ConversationId); var participationNotification = new EntityNotification <Participation>(participation, NotificationType.Create); IEnumerable <int> conversationParticipantUserIds = conversationParticipants.Select(conversationParticipation => conversationParticipation.UserId); ClientManager.SendMessageToClients(participationNotification, conversationParticipantUserIds); List <Participation> otherParticipants = conversationParticipants.Where(conversationParticipant => !conversationParticipant.Equals(participation)).ToList(); otherParticipants.ForEach( otherParticipant => ClientManager.SendMessageToClient(new EntityNotification <Participation>(otherParticipant, NotificationType.Create), participation.UserId)); Conversation conversation = conversationRepository.FindEntityById(participation.ConversationId); SendConversationNotificationToParticipants(conversation, participation.UserId, otherParticipants); }
private void OnUserAvatarUpdated(User user) { var avatarNotification = new EntityNotification <Avatar>(user.Avatar, NotificationType.Update); ClientManager.SendMessageToClients(avatarNotification); }
private void OnUserConnectionUpdated(User user) { var userNotification = new EntityNotification <ConnectionStatus>(user.ConnectionStatus, NotificationType.Update); ClientManager.SendMessageToClients(userNotification); }
private void OnUserAdded(object sender, EntityChangedEventArgs <User> e) { var userNotification = new EntityNotification <User>(e.Entity, NotificationType.Create); ClientManager.SendMessageToClients(userNotification); }