Esempio n. 1
0
        private void AttemptConnect()
        {
            if (usernameBox.Text.Length > 2)
            {
                if (ipBox.Text.Length > 0)
                {
                    if (portBox.Text.Length == 4)
                    {
                        UpdateErrorLogWindow("Connecting...");

                        _client.SetUsername(usernameBox.Text);
                        _client.SetIP(ipBox.Text);
                        _client.SetPort(Int32.Parse(portBox.Text));

                        if (_client.TCPConnect())
                        {
                            _client.SetWindowCloseAction(WindowCloseAction.OPEN_CHAT_WINDOW);
                            this.Close();
                        }
                        else
                        {
                            UpdateErrorLogWindow("Connection Failed.");
                        }
                    }
                    else
                    {
                        UpdateErrorLogWindow("Please enter a valid port.");
                    }
                }
                else
                {
                    UpdateErrorLogWindow("Please enter an IP.");
                }
            }
            else
            {
                UpdateErrorLogWindow("Username must be three characters or more.");
            }
        }