/* 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();
        }
Пример #2
0
        /// <summary>
        /// Generate a RequestDelegate that renders a Mustache view.
        /// </summary>
        private RequestDelegate GenerateMustacheRequestDelegate(string viewName)
        {
            var lightrail = new LightrailClient
            {
                ApiKey       = Environment.GetEnvironmentVariable("LIGHTRAIL_API_KEY"),
                SharedSecret = Environment.GetEnvironmentVariable("LIGHTRAIL_SHARED_SECRET")
            };

            return(async(context) =>
            {
                var filePath = Path.Combine(Directory.GetCurrentDirectory(), "..", "shared", "views", $"{viewName}.html");
                var data = new {
                    title = Environment.GetEnvironmentVariable("TITLE"),
                    orderTotal = int.Parse(Environment.GetEnvironmentVariable("ORDER_TOTAL")),
                    orderTotalDisplay = int.Parse(Environment.GetEnvironmentVariable("ORDER_TOTAL")) / 100.0,
                    currency = "USD",
                    stripePublicKey = Environment.GetEnvironmentVariable("STRIPE_PUBLISHABLE_KEY"),
                    shopperId = Environment.GetEnvironmentVariable("SHOPPER_ID"),
                    shopperToken = lightrail.GenerateShopperToken(new Lightrail.Model.ContactIdentifier {
                        ShopperId = Environment.GetEnvironmentVariable("SHOPPER_ID")
                    })
                };
                await context.Response.WriteAsync(Render.FileToString(filePath, data));
            });
        }
        /* 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();
        }
Пример #5
0
 public static void MyClassCleanup()
 {
     m_client1.StopDeliveries();
     m_client1 = null;
 }
Пример #6
0
 public static void MyClassInitialize(TestContext testContext)
 {
     m_client1 = new LightrailClient("Client1", "Desc");
     m_client1.StartDeliveries();
 }