예제 #1
0
        private async void connectButton_Click(object sender, EventArgs e)
        {
            connectButton.Enabled = false;
            string input = ipInput.Text;

            if (input.IsIPv4Format() && IPAddress.TryParse(input, out IPAddress ip))
            {
                LSClient client = new LSClient();
                resultLabel.Text = "Connecting...";
                if (await client.TryConnectAsync(ip, 1337))
                {
                    ConnectionMade?.Invoke(client);
                    resultLabel.Text = "";
                }
                else
                {
                    resultLabel.Text = "Connection failed";
                }
            }
            else
            {
                resultLabel.Text = "Invalid IP entered";
            }
            connectButton.Enabled = true;
        }
예제 #2
0
        private async void connectButton_Click(object sender, EventArgs e)
        {
            connectButton.Enabled = false;
            LSClient client = new LSClient();

            if (await client.TryConnectAsync(IPAddress.Parse(selectedConnection.ConnectionIP), 1337))
            {
                Console.WriteLine("Waiting for server info...");
                ServerInfoMessage serverInfo = await new RequestManager(client).RetrieveServerInfo();
                //Console.WriteLine("Received server info: " +
                //  JsonConvert.SerializeObject(serverInfo, Formatting.Indented));
                new ConnectedClientForm(client, serverInfo).ShowDialog(this);
                client.Close();
            }
            connectButton.Enabled = true;
        }