public async Task StartNewConversationAsync(string accessToken, Guid receiverId, ConversationViewModel conversation) { var cloned = conversation.ShallowClone(); cloned.IsToReceiver = true; foreach (var userClient in WebSocketConnectionManager.GetClientByUserId(receiverId)) { await InvokeClientMethodAsync(userClient.Key, "StartNewConversation", new[] { cloned }); } }
public async Task SendChatMessageToRecipientAsync(string accessToken, Guid senderId, ConversationMessageViewModel conversationMessage) { foreach (var userClient in WebSocketConnectionManager.GetClientByUserId(conversationMessage.ReceiverId)) { await InvokeClientMethodAsync(userClient.Key, "ChatMessageReceived", new[] { conversationMessage }); } foreach (var userClient in WebSocketConnectionManager.GetClientByUserId(senderId)) { await InvokeClientMethodAsync(userClient.Key, "ChatMessageReceived", new[] { conversationMessage }); } }
public async Task GetAllNotificationsAsync(ClaimsPrincipal user) { var nameClaim = user.FindFirst(ClaimTypes.NameIdentifier); var userId = Guid.Parse(nameClaim.Value); var connections = WebSocketConnectionManager.GetConnectionIdsByUserId(userId); if (!connections.Any()) { return; } var notifications = await GetNotificationsAsync(user, userId); foreach (var userConnection in connections) { await InvokeClientMethodAsync(userConnection, "GetAllNotifications", new[] { notifications }); } }
public NotificationsMessageHandler(INotificationsDataProvider notificationsDataProvider, IAuthorizationService authService, WebSocketConnectionManager webSocketConnectionManager) : base(webSocketConnectionManager) { _notificationsDataProvider = notificationsDataProvider; _authService = authService; }
public WebSocketHandler(WebSocketConnectionManager webSocketConnectionManager) { WebSocketConnectionManager = webSocketConnectionManager; }