public MainPage() { InitializeComponent(); EndpointAddress address = new EndpointAddress("http://localhost:2646/DuplexService.svc"); PollingDuplexHttpBinding binding = new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll); DuplexServiceClient proxy = new DuplexServiceClient(binding, address); proxy.ReceiveReceived += (sender, args) => { if (args.order.Status == OrderStatus.Completed) { String reply = ""; reply = "Here is the completed order:\n"; foreach (var order in args.order.Payload) { reply += order + "\n"; } MessageBox.Show(reply); } else { MessageBox.Show("processing"); } }; proxy.OrderAsync("widget", 3); }
/// <summary> /// 连接聊天服务器 /// </summary> public void ConnectionChatService() { if (null == client) { var end = new EndpointAddress("http://localhost:6667/PlatformChat.svc"); var binding = new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll); client = new PlatformChatClient(new InstanceContext(this), binding, end); } }
public MainPage() { InitializeComponent(); EndpointAddress address = new EndpointAddress("http://localhost:" + HtmlPage.Document.DocumentUri.Port + "/DuplexService.Web/AsyncTask.svc"); PollingDuplexHttpBinding binding = new PollingDuplexHttpBinding(); client = new AsyncTaskServiceClient(binding, address); client.ReturnResultReceived += client_ReturnResultReceived; }
public MainPage() { InitializeComponent(); // Setup up client channel for the Polling Service var address = new EndpointAddress("http://localhost:7101/OrderPollingService.svc"); var binding = new PollingDuplexHttpBinding(); _pollingClient = new OrderPollingServiceClient(binding, address); _pollingClient.CancelOrderResponseReceived += OnCancelOrderResponseReceived; _pollingClient.ReceiveOrderCancellationsReceived += OnReceiveOrderCancellationsReceived; _pollingClient.GetOrderCancellationsAsync(); }
/// <summary> /// Creates a new contact center service based on the endpoint uri. /// </summary> /// <param name="endpointUri">Endpoint uri. Cannot be null or empty.</param> public ContactCenterService(string endpointUri) { if (String.IsNullOrEmpty(endpointUri)) { throw new ArgumentException("Endpoint uri is not valid", endpointUri); } EndpointAddress address = new EndpointAddress(endpointUri); PollingDuplexHttpBinding binding = new PollingDuplexHttpBinding(); m_contactCenterWcfServiceClient = new ContactCenterWcfServiceClient(binding, address); this.RegisterEventHandlers(this.WcfClient); }
private void Init(Uri serverUri) { // Create a channel factory capable of producing a channel of type IDuplexSessionChannel IChannelFactory <IDuplexSessionChannel> factory = new PollingDuplexHttpBinding().BuildChannelFactory <IDuplexSessionChannel>(); Open(factory); // Address of the polling duplex server and creation of the channel to that endpoint EndpointAddress endPoint = new EndpointAddress(serverUri.ToString()); _channel = factory.CreateChannel(endPoint); Open(_channel); // Use the thread pool to start only one asynchronous request to Receive messages from the server // Only start another asynchronous request when a signal is received that the first thread pool thread has received something ThreadPool.RegisterWaitForSingleObject(_waitObject, delegate { Receive(_channel, CompleteReceive); }, null, Timeout.Infinite, false); _waitObject.Set(); }
public ServerCommunicator() { //TODO: exceptions handling! var address = new EndpointAddress("http://localhost:4379/DuplexService.svc"); var binding = new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll); myProxy = new DuplexServiceClient(binding, address); myProxy.StartLoginCompleted += StartLoginCompleted; myProxy.AuthorizeLoginCompleted += AuthorizeLoginCompleted; myProxy.CreateNewGameCompleted += CreateNewGameCompleted; myProxy.StartAuthorizePlayerCompleted += StartAuthorizePlayerCompleted; myProxy.AuthorizePlayerCompleted += AuthorizePlayerCompleted; myProxy.ReceiveGameEventsReceived += ReceiveGameEventsReceived; myProxy.ReadyStatusChangeReceived += ReadyStatusChangeReceived; myProxy.StartGameReceived += (sender, args) => { if (Game != null) myStartGameHandler(); else myStartGameOnGameSet = true; }; }