コード例 #1
0
ファイル: client.cs プロジェクト: yongzhao1/dotnet-samples
        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");
            client.Subscribe();

            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();
        }
コード例 #2
0
        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
ファイル: client.cs プロジェクト: trade-nexus/trade-mirror
        static void Main(string[] args)
        {
            try
            {
                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");
                Logger.Info("Subscribing", _oType.FullName, "Main");

                if (client.Subscribe("umerazizmalik", "abdulaziz"))
                {
                    //client.PublishPriceChange("HELLO");

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

                    Console.WriteLine("Unsubscribing");
                    Logger.Info("Unsubscribing", _oType.FullName, "Main");
                    client.Unsubscribe();

                    //Closing the client gracefully closes the connection and cleans up resources
                    client.Close();
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine("Invalid Client Credentials");
                    Console.ReadLine();

                    //Closing the client gracefully closes the connection and cleans up resources
                    client.Close();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }