Ejemplo n.º 1
0
        public static void PublishEvents(int numberEvents, string topic, int interval_ms)
        {
            for (int i = 0; i < numberEvents; ++i)
            {
                //Publisher.broker.SendContent(new Event(topicname,"banana"));

                // No replication
                //PublishTopicDelegate del = new PublishTopicDelegate( Publisher.broker.SendContentPub );

                // Replication
                PublishTopicDelegate del = new PublishTopicDelegate(Publisher.brokerCircle.SendContentPub);

                AsyncCallback remoteCallback = new AsyncCallback(PublishAsyncCallBack);
                EventCounter  eCounter       = getCountAndIncrement(topic);
                Console.WriteLine("Sending to " + brokerCircle.name + " : " + topic + " " + eCounter.topicCounter + " " + eCounter.globalCounter);
                IAsyncResult remAr = del.BeginInvoke(new Event(topic, Publisher.name + "_" + eCounter.topicCounter, Publisher.name, eCounter.topicCounter, eCounter.globalCounter), Publisher.name, remoteCallback, null);

                //Publisher.puppetMaster.Log( "PubEvent" );
                PublishPuppetLog logDel            = new PublishPuppetLog(Publisher.puppetMaster.Log);
                AsyncCallback    remoteCallbackLog = new AsyncCallback(PublishLogCallBack);
                IAsyncResult     remArLog          = logDel.BeginInvoke("PubEvent " + Publisher.name + ", " + topic + ", " + eCounter.topicCounter, remoteCallbackLog, null);

                Thread.Sleep(interval_ms);
            }
        }
Ejemplo n.º 2
0
        static EventCounter getCountAndIncrement(string topic)
        {
            EventCounter ec = new EventCounter();

            if (!topicCount.ContainsKey(topic))
            {
                topicCount.Add(topic, 0);
            }
            lock (lockObject)
            {
                ec.globalCounter = count++;
                ec.topicCounter  = topicCount[topic]++;
            }
            return(ec);
        }
Ejemplo n.º 3
0
 static EventCounter getCountAndIncrement( string topic )
 {
     EventCounter ec = new EventCounter();
     if ( !topicCount.ContainsKey( topic ) ) {
         topicCount.Add( topic, 0 );
     }
     lock (lockObject)
     {
         ec.globalCounter = count++;
         ec.topicCounter = topicCount[ topic ]++;
     }
     return ec;
 }