Ejemplo n.º 1
0
        /// <summary>
        /// Event handler for the listen button of the server GUI. When
        /// the user selects the listen button of the server, a host
        /// channel is created and opened which will be used by the client
        /// to communicate with the server. The port number and the server
        /// IP address can be entered in the GUI.
        /// </summary>
        /// <param name="sender">The default sender object for which the callback is
        /// associated</param>
        /// <param name="e">Platform event object for the button click operation</param>
        private void ListenButton1_Click(object sender, RoutedEventArgs e)
        {
            string localPort1 = RemotePortTextBox1.Text;
            string endpoint1  = RemoteAddressTextBox1.Text + localPort1 + "/IBasicService";

            try
            {
                if (localPort1.Equals("") || RemoteAddressTextBox1.Text.Equals(""))
                {
                    throw new Exception("Input URI not proper. Please provide valid URL");
                }
                String projectLocation = "";
                server = new ServerHost();
                server.CreateReceiveChannel(endpoint1);
                listBox1.Items.Insert(0, "Started.. Waiting for a Client");
                ListenButton1.IsEnabled = false;
                StopButton.IsEnabled    = true;
                projectLocation         = "The test files directory is " + Directory.GetCurrentDirectory();
                listBox1.Items.Insert(1, projectLocation);
                BrowseButton.IsEnabled = true;
                selectedFolderPath     = Directory.GetCurrentDirectory();
                UpdateFileContents();
            }
            catch (Exception ex)
            {
                Window        temp = new Window();
                StringBuilder msg  = new StringBuilder(ex.Message);
                msg.Append("\nport = ");
                msg.Append(localPort1.ToString());
                temp.Content = msg.ToString();
                temp.Height  = 100;
                temp.Width   = 500;
                temp.Show();
            }
        }