public void SubscribeToNewChatNotifications(long userId, Action <Chat> chatConsumer)
 {
     _socketProvider.Subscribe($"newChatNotification-{userId}",
                               $"user/{userId}/notifications", stompMessage =>
     {
         var notification = JsonConvert.DeserializeObject <Notification>(stompMessage.Body);
         if (notification.Type == NotificationType.NEW_CHAT)
         {
             chatConsumer?.Invoke(DeserializeChat(notification.Text));
         }
     });
 }
Пример #2
0
 public void SubscribeToChat(long id, Action <Message> messageConsumer)
 {
     _socketProvider.Subscribe($"chat-{id}", $"chat/{id}", stompMessage =>
     {
         var message = JsonConvert.DeserializeObject <Message>(stompMessage.Body);
         messageConsumer?.Invoke(message);
     });
 }