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; }
protected virtual void OnConnectionMade() { ConnectionMade?.Invoke(this, new ConnectionEventArgs() { socket = _connectedUser }); }