Connect() public static method

Connect to a server with the given IPEndPoint
public static Connect ( string IP, string _Username, string _Password, string _SrvPassword ) : bool
IP string
_Username string
_Password string
_SrvPassword string
return bool
Ejemplo n.º 1
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            foreach (Control ctrl in this.Controls)
            {
                errorProvider.SetError(ctrl, "");
            }

            bool berror = false;

            if (this.txtUsername.Text == "")
            {
                errorProvider.SetError(txtUsername, "Username not specified");
                berror = true;
            }
            if (this.txtPassword.Text == "")
            {
                errorProvider.SetError(txtPassword, "Password not specified");
                berror = true;
            }
            if (this.txtServerIP.Text == "")
            {
                errorProvider.SetError(txtServerIP, "Server not specified");
                berror = true;
            }
            if (berror)
            {
                return;
            }

            btnConnect.Text    = "Connecting...";
            btnConnect.Enabled = false;

            if (
                SMPInterface.Connect(txtServerIP.Text, txtUsername.Text, txtPassword.Text, txtSrvPassword.Text)
                )
            {
                this.Close();
            }
            else
            {
                btnConnect.Text    = "Connect";
                btnConnect.Enabled = true;
                errorProvider.SetError(btnConnect, SMPInterface.LastError);
            }
        }