예제 #1
0
        /// <summary>
        /// Click Accept triggers attempt to connect to server
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Accept1_Click(object sender, EventArgs e)
        {
            servername = ServerInput1.Text + ".eng.utah.edu";

            // Attempt to connect to the server.  We want this blocking and to only exit upon success.
            Networking.ConnectToServer(Connected, servername);

            System.Threading.Thread.Sleep(800);

            if (warden != null) /* <<< Replace with connection success bool*/
            // If connection successful, open Document Name Dialog and close this window
            {
                SpreadsheetContext.getAppContext().RunForm(new DocNameDialog(warden));

                Close();
            }
            else
            {
                // connection failed should let the user know that something went wrong
                DialogResult badConnect = MessageBox.Show("Connection to Server failed.",
                                                          "Connection Failure Warning",
                                                          MessageBoxButtons.OK,
                                                          MessageBoxIcon.Warning);
            }
        }
        /// <summary>
        /// Atttemps to connect to a server at address
        /// </summary>
        /// <param name="address">The address of the server we are connecting to </param>
        /// <param name="name">The name of the client connecting</param>
        public void Connect(string address, string name)
        {
            // save the name of the client connecting
            clientName = name;

            // Attempt to connect to the server
            Networking.ConnectToServer(OnConnect, address, 1100);
        }
예제 #3
0
        /*/// <summary>
         * /// Attempt to connect to the server when this button is clicked.
         * /// </summary>
         * /// <param name="sender">The sender.</param>
         * /// <param name="e">The EventArgs.</param>
         * private void button2_Click(object sender, EventArgs e)
         * {
         *  this.server = Networking.ConnectToServer(new Action<SocketState>(this.FirstContact), this.serverTextBox.Text);
         * }*/

        private void ConnectToServer(string serverAddress)
        {
            this.server = Networking.ConnectToServer(new Action <SocketState>(this.FirstContact), serverAddress);
        }