private void OnClientStateChanged(object sender, bool connected) { if (listClients.InvokeRequired) { listClients.Invoke((MethodInvoker)(() => { OnClientStateChanged(sender, connected); })); return; } ClientNode node = (ClientNode)sender; if (connected) { ListViewItem client = new ListViewItem(); client.Tag = node; listClients.Items.Add(client); node.Send(new IdentificationPacket()); } else { foreach (ListViewItem item in listClients.Items) { if (item.Tag == node) { listClients.Items.Remove(item); break; } } } }
private void btnClientDisconnect_Click(object sender, System.EventArgs e) { foreach (ListViewItem item in listClients.SelectedItems) { ClientNode node = (ClientNode)item.Tag; node.Send(new DoShutdownPacket()); } }