示例#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 });
            }
        }
示例#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 });
            }
        }
示例#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 });
            }
        }
示例#4
0
 public NotificationsMessageHandler(INotificationsDataProvider notificationsDataProvider, IAuthorizationService authService, WebSocketConnectionManager webSocketConnectionManager)
     : base(webSocketConnectionManager)
 {
     _notificationsDataProvider = notificationsDataProvider;
     _authService = authService;
 }
示例#5
0
 public WebSocketHandler(WebSocketConnectionManager webSocketConnectionManager)
 {
     WebSocketConnectionManager = webSocketConnectionManager;
 }