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(); }
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(); }
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(); }
public static void Main(string[] args) { _site = new InstanceContext(new DataSource()); _client = new SampleContractClient(_site); while (true) { ReadDataFromSocket(); } }
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); } }
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(); }