/* Requester */
        static void cMain(string[] args)
        {
            // create the cient
            LightrailClient client = new LightrailClient("name", "description");

            // start the client
            client.StartDeliveries();

            // register the requester terminal
            client.RegisterTerminal(TerminalStandpoint.Requester, "ReqTerminal", "ReqDesc",
                                    "[Global>Company>Region>Domain>App>Instance>Request]");

            // create a request message
            Delivery request = new Delivery("This is a string message that will be encoded as UTF-8");

            // send the request and get the response with a 30 second timeout
            DetailedDelivery response = client.Request("ReqTerminal", request, 30000);

            // parse the response
            string responseString = response.MessageString();

            // send more and more and more requests

            // close the instance
            client.StopDeliveries();
        }
        /* Responder */
        static void dMain(string[] args)
        {
            // create the cient
            LightrailClient client = new LightrailClient("name", "description");

            // set up callback
            client.OnRequestReceived += new RequestReceived(client_OnRequestReceived);

            // start the client
            client.StartDeliveries();

            // register the responder terminal
            client.RegisterTerminal(TerminalStandpoint.Responder, "RespTerminal", "RespDesc",
                                    "[Global>Company>Region>Domain>App>Instance>Request]");

            // wait for any and all messages to be requests to be delivered

            // close the instance
            client.StopDeliveries();
        }
        /* Publisher */
        static void aMain(string[] args)
        {
            // create the cient
            LightrailClient client = new LightrailClient("name", "description");

            // start the client
            client.StartDeliveries();

            // register the publisher terminal
            client.RegisterTerminal(TerminalStandpoint.Publisher, "PubTerminal", "PubDesc",
                                    "[Global>Company>Region>Domain>App>Instance>Publish]");

            // create a message
            Delivery message = new Delivery("This is a string message that will be encoded as UTF-8");

            // send the message
            client.Publish("PubTerminal", message);

            // send more and more and more messages

            // close the instance
            client.StopDeliveries();
        }
Beispiel #4
0
        public void BasicTerminalTest()
        {
            m_client1.RegisterTerminal(TerminalStandpoint.Publisher, "Pub", "Desc", "[Test>Basic]");
            m_client1.RegisterTerminal(TerminalStandpoint.Subscriber, "Sub", "Desc", "[Test>");
            Thread.Sleep(1000);

            PublishReceived evnt = new PublishReceived(m_client1_OnPublishReceived);

            m_client1.OnPublishReceived += evnt;

            m_wait.Reset();
            m_numExpected = 1;

            Delivery d = new Delivery("Test");

            SetDeliveryAttributes(d, new string[] { "Sub" }, "Pub");

            m_client1.Publish("Pub", d);

            Assert.IsTrue(m_wait.WaitOne(5000));

            m_client1.OnPublishReceived -= evnt;
            m_client1.DeregisterTerminal(TerminalStandpoint.Publisher, "Pub");
            m_client1.DeregisterTerminal(TerminalStandpoint.Subscriber, "Sub");
        }