示例#1
0
        static void Main(string[] args)
        {
            InstanceContext      site   = new InstanceContext(new Client());
            SampleContractClient client = new SampleContractClient(site);

            Console.WriteLine("Sending PublishPriceChange(Gold, 400.00D, -0.25D)");
            client.PublishPriceChange("Gold", 400.00D, -0.25D);

            Console.WriteLine("Sending PublishPriceChange(Silver, 7.00D, -0.20D)");
            client.PublishPriceChange("Silver", 7.00D, -0.20D);

            Console.WriteLine("Sending PublishPriceChange(Platinum, 850.00D, +0.50D)");
            client.PublishPriceChange("Platinum", 850.00D, +0.50D);

            Console.WriteLine("Sending PublishPriceChange(Gold, 401.00D, 1.00D)");
            client.PublishPriceChange("Gold", 401.00D, 1.00D);

            Console.WriteLine("Sending PublishPriceChange(Silver, 6.60D, -0.40D)");
            client.PublishPriceChange("Silver", 6.60D, -0.40D);

            Console.WriteLine();
            Console.WriteLine("Press ENTER to shut down data source");
            Console.ReadLine();

            //Closing the client gracefully closes the connection and cleans up resources
            client.Close();
        }
        static void Main(string[] args)
        {
            InstanceContext      site   = new InstanceContext(null, new Client());
            SampleContractClient client = new SampleContractClient(site);

            //create a unique callback address so multiple clients can run on one machine
            WSDualHttpBinding binding = (WSDualHttpBinding)client.Endpoint.Binding;
            string            clientcallbackaddress = binding.ClientBaseAddress.AbsoluteUri;

            clientcallbackaddress    += Guid.NewGuid().ToString();
            binding.ClientBaseAddress = new Uri(clientcallbackaddress);

            //Subscribe.
            Console.WriteLine("Subscribing");
            var marketData = new MarketData {
                businessDate = DateTime.Now, StockPrice = 1000
            };

            client.Subscribe();
            //Console.Write("Publishing: ");
            //Console.WriteLine("PriceChange(businessDate {0}, price {1})", marketData.businessDate.ToShortDateString(), marketData.StockPrice.ToString("C"));
            client.PublishPriceChange(new MarketData {
                businessDate = DateTime.Now, StockPrice = 1000
            });

            Console.WriteLine();
            Console.WriteLine("Press ENTER to unsubscribe and shut down client");
            Console.ReadLine();

            Console.WriteLine("Unsubscribing");
            client.Unsubscribe();

            //Closing the client gracefully closes the connection and cleans up resources
            client.Close();
        }
示例#3
0
        /// <summary>
        /// Processes the data received
        /// </summary>
        private static void ProcessDataReceived(string signalInformation)
        {
            try
            {
                Logger.Debug("New Signal received = " + signalInformation, _oType.FullName, "ProcessDataReceived");
                Console.WriteLine("New Signal received = " + signalInformation);

                _client.PublishPriceChange(signalInformation);
            }
            catch (Exception ex)
            {
                Logger.Error("Exception = " + ex.Message, _oType.FullName, "ProcessDataReceived");
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            InstanceContext      site   = new InstanceContext(new Client());
            SampleContractClient client = new SampleContractClient(site);

            MarketData marketData = new MarketData();

            marketData.businessDate = DateTime.Parse("2015-02-13");
            marketData.StockPrice   = 1000;

            Console.WriteLine("Sending PublishPriceChange(marketData)");
            //client.PublishPriceChange("Gold", 400.00D, -0.25D);
            client.PublishPriceChange(marketData);



            Console.WriteLine();
            Console.WriteLine("Press ENTER to shut down data source");
            Console.ReadLine();

            //Closing the client gracefully closes the connection and cleans up resources
            client.Close();
        }