public void PubSubTest()
        {
            UdpBus bus = (UdpBus)Reflector.GetField(this.pool, "bus");

            object received = null;

            System.Threading.AutoResetEvent evt = new System.Threading.AutoResetEvent(false);

            this.pool.Start();

            HostConfiguration hostSpec = new HostConfiguration(0)
            {
                CameraID = 2, Name = "mike",
            };

            bus.Publish(Topics.HostReply, hostSpec, 3000);

            System.Threading.Thread.Sleep(6000);

            var host = this.pool[hostSpec.StationID];

            Assert.IsNotNull(host);

            Assert.AreEqual("mike", host.Config.Name);

            hostSpec.Name = "jack";

            bus.Publish(Topics.HostReply, hostSpec, 3000);

            System.Threading.Thread.Sleep(6000);

            host = this.pool[hostSpec.StationID];
            Assert.AreEqual("jack", host.Config.Name);
        }
示例#2
0
        public HostsPool(string announceIp, int port)
        {
            RaiseListChangedEvents = true;

            bus = new UdpBus(announceIp, port);

            bus.Subscribe(Topics.HostReply, HostMessageHandler);

            worker.DoWork += new DoWorkEventHandler(worker_DoWork);
            worker.WorkerSupportsCancellation = true;

            this.Observer = new NullHostsPoolObserver();
        }
示例#3
0
        public void DoTest(string topic, object data)
        {
            using (UdpBus bus = new UdpBus("224.0.0.23", 40001))
            {
                object received = null;

                bus.Subscribe(topic, (o, e) =>
                {
                    System.Diagnostics.Debug.WriteLine(e.DataObject.ToString());
                    received = e.DataObject;
                    Assert.AreEqual(data, received);
                });

                bus.Start();

                bus.Publish(topic, data, 3000);

                System.Threading.Thread.Sleep(3000);
            }
        }
 public Communication(string ip, int port)
 {
     bus = new UdpBus(ip, port);
     bus.Subscribe(Topics.CenterQuery, OnCenterQuery);
 }