Esempio 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) );
        }
        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;
        }