Exemplo n.º 1
0
        void Forward(Message message, Interactor sender)
        {
            switch (message.MessageType)
            {
                case MessageType.SubscriptionRequest:
                    {
                        var subscriptionRequest = (SubscriptionRequest)message;
                        _messageBus.SubscriptionRequests.OnNext(SourceMessage.Create(sender, subscriptionRequest));
                        _messageBus.ForwardedSubscriptionRequests.OnNext(new ForwardedSubscriptionRequest(sender.Id, subscriptionRequest.Topic, subscriptionRequest.IsAdd));
                    }
                    break;

                case MessageType.MulticastData:
                    _messageBus.PublishedMulticastDataMessages.OnNext(SourceMessage.Create(sender, (MulticastData)message));
                    break;

                case MessageType.UnicastData:
                    _messageBus.PublishedUnicastDataMessages.OnNext(SourceMessage.Create(sender, (UnicastData)message));
                    break;

                case MessageType.NotificationRequest:
                    _messageBus.NotificationRequests.OnNext(SourceMessage.Create(sender, (NotificationRequest)message));
                    break;

                default:
                    throw new ArgumentException("invalid message type");
            }
        }
Exemplo n.º 2
0
 void Write(Message message)
 {
     using (var frameStream = new MemoryStream())
     {
         message.Write(frameStream);
         _writer.Write(new FrameContent(frameStream.GetBuffer(), (int)frameStream.Length));
     }
 }