Exemplo n.º 1
0
        private void thread_Client(object Logbus)
        {
            try
            {
                ILogBus ctrl = Logbus as ILogBus;
                ctrl.CreateChannel("simple", "Simple", new TrueFilter(), "Very simple channel", 0);
                Dictionary <string, string> input;
                input = new Dictionary <string, string>();
                IEnumerable <KeyValuePair <string, string> > output;
                input.Add("ip", "127.0.0.1");
                input.Add("port", MONITOR_PORT.ToString());
                string clientid = ctrl.SubscribeClient("simple", "udp", input, out output);
                TestContext.WriteLine("Client ID obtained by logbus: {0}", clientid);

                //Go ahead and send
                step1.Set();


                IPEndPoint remote_ep = new IPEndPoint(IPAddress.Any, 0);
                using (UdpClient client = new UdpClient(MONITOR_PORT))
                {
                    byte[]        payload = client.Receive(ref remote_ep);
                    SyslogMessage msg     = SyslogMessage.Parse(payload);
                    TestContext.WriteLine("Message1: {0}", msg);
                    payload = client.Receive(ref remote_ep);
                    msg     = SyslogMessage.Parse(payload);
                    TestContext.WriteLine("Message2: {0}", msg);
                }

                ctrl.UnsubscribeClient(clientid);
                finish.Set();
            }
            catch (Exception ex) { Assert.Fail("Test failed: {0}", ex); }
        }
Exemplo n.º 2
0
        private void t2_thread_Client(object Logbus)
        {
            try
            {
                ILogBus ctrl = Logbus as ILogBus;
                ctrl.CreateChannel("simple", "Simple", new TrueFilter(), "Very simple channel", 0);
                Dictionary <string, string> input;
                input = new Dictionary <string, string>();
                IEnumerable <KeyValuePair <string, string> > output;
                input.Add("ip", "127.0.0.1");
                input.Add("port", t2_client_port.ToString());
                string clientid = ctrl.SubscribeClient("simple", "udp", input, out output);
                TestContext.WriteLine("Client ID obtained by logbus: {0}", clientid);

                //Go ahead and send
                t2_step1.Set();

                //Only 6 messages expected
                IPEndPoint remote_ep = new IPEndPoint(IPAddress.Any, 0);
                using (UdpClient client = new UdpClient(t2_client_port))
                {
                    byte[] payload = client.Receive(ref remote_ep);
                    TestContext.WriteLine("Time occurred for a message to traverse the bus: {0} milliseconds", (DateTime.Now - t2_start).TotalMilliseconds.ToString(CultureInfo.CurrentUICulture));
                    SyslogMessage msg = SyslogMessage.Parse(payload);
                }

                ctrl.UnsubscribeClient(clientid);
                t2_finish.Set();
            }
            catch (Exception ex) { Assert.Fail("Test failed: {0}", ex); }
        }
Exemplo n.º 3
0
        private void t1_thread_Client(object Logbus)
        {
            try
            {
                ILogBus ctrl = Logbus as ILogBus;
                ctrl.CreateChannel("simple", "Simple", new TrueFilter(), "Very simple channel", 0);
                Dictionary <string, string> input;
                input = new Dictionary <string, string>();
                IEnumerable <KeyValuePair <string, string> > output;
                input.Add("ip", "127.0.0.1");
                input.Add("port", t1_client_port.ToString());
                string clientid = ctrl.SubscribeClient("simple", "udp", input, out output);
                TestContext.WriteLine("Client ID obtained by logbus: {0}", clientid);

                //Go ahead and send
                t1_step1.Set();

                //Only 6 messages expected
                IPEndPoint remote_ep = new IPEndPoint(IPAddress.Any, 0);
                using (UdpClient client = new UdpClient(t1_client_port))
                    for (int i = 0; i < 5; i++)
                    {
                        byte[] payload = client.Receive(ref remote_ep);

                        SyslogMessage msg = SyslogMessage.Parse(payload);
                        Assert.AreEqual(SyslogFacility.Audit, msg.Facility);
                    }

                ctrl.UnsubscribeClient(clientid);
                t1_finish.Set();
            }
            catch (Exception ex) { Assert.Fail("Test failed: {0}", ex); }
        }
Exemplo n.º 4
0
 void IChannelSubscription.UnsubscribeChannel(string id)
 {
     try
     {
         _target.UnsubscribeClient(id);
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Required by ILogBus
 /// </summary>
 public void UnsubscribeClient(string clientId)
 {
     _target.UnsubscribeClient(clientId);
 }