private async void btnLogin_Click(object sender, EventArgs e) { if (!txtUsername.Text.Trim().Equals("")) { ClientManager clientManger = new ClientManager(txtUsername.Text); bool connected = await clientManger.Connect("127.0.0.1", 7); if (connected) { ConnectedUsers connectedForm = new ConnectedUsers(clientManger); connectedForm.Show(); Hide(); } else { MessageBox.Show("Could not connect to the server"); } } }
private void ClientConnect() { if (!string.IsNullOrEmpty(txtClientIP.Text) && nudClientPort.Value > 0 && !string.IsNullOrEmpty(txtClientNickname.Text)) { client = new ClientManager(txtClientIP.Text, (int)nudClientPort.Value, txtClientNickname.Text); client.Connect(txtClientPassword.Text); if (client != null && client.IsConnected) { client.Notification += client_Notification; client.MessageReceived += client_MessageReceived; client.UserConnected += client_UserConnected; client.UserDisconnected += client_UserDisconnected; client.UserListReceived += client_UserListReceived; client.Kicked += client_Kicked; client.Pong += client_Pong; ClientConnected = true; } } }