protected virtual void OnClientConEventsArgs(ClientsConEventArgs e) { EventHandler <ClientsConEventArgs> handler = OnClientConEventArgs; if (handler != null) { handler(this, e); } }
private void HandlClientCon(object sender, ClientsConEventArgs e) { id++; string ip = ((IPEndPoint)(e.NewClient.Client.RemoteEndPoint)).Address.ToString(); IPHostEntry hostname = Dns.GetHostEntry(ip); dGV.Rows.Add(id, hostname.HostName, ip, DateTime.Now.ToLongTimeString()); winShell l = shellbox(id, this, e.NewClient); l.IP = ip; l.isRun = true; l.Show(); Shells.Add(l); }
public async void OnStartServer(int Port = 443) { server = new TcpListener(IPAddress.Any, Port); try { server.Start(); IsRunning = true; while (IsRunning) { var Client = await server.AcceptTcpClientAsync(); AddShell(Client); ClientsConEventArgs clientsCon = new ClientsConEventArgs(Client); OnClientConEventsArgs(clientsCon); } } catch (Exception ex) { MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }