Esempio n. 1
0
        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 });
            }
        }
Esempio n. 2
0
        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 });
            }
        }
Esempio n. 3
0
        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 });
            }
        }
Esempio n. 4
0
 public NotificationsMessageHandler(INotificationsDataProvider notificationsDataProvider, IAuthorizationService authService, WebSocketConnectionManager webSocketConnectionManager)
     : base(webSocketConnectionManager)
 {
     _notificationsDataProvider = notificationsDataProvider;
     _authService = authService;
 }
Esempio n. 5
0
 public WebSocketHandler(WebSocketConnectionManager webSocketConnectionManager)
 {
     WebSocketConnectionManager = webSocketConnectionManager;
 }