Ejemplo n.º 1
0
        public void Subscribe(string topic, EventHandler<TopicArgs> handler)
        {
            TopicSubscriber topicSubscriber = new TopicSubscriber(topic, factory);
            topicSubscriber.Start();

            topicSubscriber.TopicMessageEvent += msgParser => handler( msgParser.EndPoint, new TopicArgs(msgParser) );
        }
Ejemplo n.º 2
0
        public IDisposable Subscribe(string topicPattern, Action<string, object> messageConsumer)
        {
            var topicSubscriber = new TopicSubscriber(topicPattern, MessageParserFactory);
            topicSubscriber.TopicMessageEvent += messageParser =>
                                                     {
                                                         object o = messageParser.ParseObject();
                                                         messageConsumer(messageParser.Topic, o);
                                                     };
            topicSubscriber.Start();

            return topicSubscriber;
        }