//----< subscribe to new message events and Intialize Window component >------------------------ public WindowMain() { InitializeComponent(); Title = "Client2"; IPHostEntry host1; string localIP = "?"; host1 = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host1.AddressList) { if (ip.AddressFamily.ToString() == "InterNetwork") { localIP = ip.ToString(); } } string address = "http://" + localIP + ":8002/MessageService"; ServiceHost host = ProgClient.CreateServiceChannel(address); host.Open(); OnNewMessage += new NewMessage(OnNewMessageHandler); combobox_1.Items.Add("http://localhost:9001/MessageService"); combobox_1.Items.Add("http://localhost:9002/MessageService"); Connect.IsEnabled = false; Dependency_Button.IsEnabled = false; result.IsEnabled = false; message.IsEnabled = false; }
/// <summary> /// creates a connection to server2 if not already connected by fetching the port number seleted by the user /// </summary> void getConnection2() { if (ConnectButton2.IsEnabled) { server2Port = RemotePortTextBox2.Text; endPoint2 = RemoteAddressTextBox2.Text; string endpoint = endPoint2 + ":" + server2Port + "/IBasicService"; try { if (client == null) { client = new ProgClient(); } svcServer2Channel = client.CreateSendChannel(endpoint); } catch (Exception ex) { showErrorWindow(ex.Message, server2Port); } } }