public DataForm(ServerWorker worker, HandleWorker endWorking)
 {
     InitializeComponent();
     this.worker         = worker;
     this.endWorking     = endWorking;
     this.labelName.Text = worker.client.RemoteEndPoint.ToString();
     pos = 0;
 }
 private void listClient_SelectedIndexChanged(object sender, EventArgs e)
 {
     foreach (ListViewItem listViewItem in listClient.SelectedItems)
     {
         string       name   = listViewItem.Text;
         ServerWorker worker = workers.Where(p => p.Key.client.RemoteEndPoint.ToString().Equals(name)).FirstOrDefault().Key;
         bool         status = workers[worker];
         if (!status)
         {
             DataForm dataForm = new DataForm(worker, EndForm);
             dataForm.Show();
             workers[worker] = true;
         }
     }
 }
 public void AddToListClient(ServerWorker worker)
 {
     workers[worker] = false;
     if (listClient.InvokeRequired)
     {
         HandleWorker a = new HandleWorker(AddToListClient);
         Invoke(a, new object[] { worker });
     }
     else
     {
         ListViewItem listViewItem = new ListViewItem(worker.client.RemoteEndPoint.ToString());
         listViewItem.SubItems.Add(worker.client.Connected.ToString());
         this.listClient.Items.Add(listViewItem);
     }
 }
 public void Run()
 {
     server.socket.Listen(10);
     while (isRun)
     {
         Thread.Sleep(30);
         try
         {
             Socket       client = server.socket.Accept();
             ServerWorker worker = new ServerWorker(client, removeWorker);
             server.workers.Add(worker);
             new Thread(worker.Run).Start();
             addWorker(worker);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.StackTrace);
         }
     }
 }
 public void RemoveFromListClient(ServerWorker worker)
 {
     if (listClient.InvokeRequired)
     {
         HandleWorker a = new HandleWorker(RemoveFromListClient);
         Invoke(a, new object[] { worker });
     }
     else
     {
         string ep = worker.client.RemoteEndPoint.ToString();
         foreach (ListViewItem listViewItem in listClient.Items)
         {
             if (listViewItem.Text.Equals(ep))
             {
                 listClient.Items.Remove(listViewItem);
                 break;
             }
         }
         listClient.Refresh();
     }
 }
 private void EndForm(ServerWorker worker)
 {
     workers[worker] = false;
 }
Esempio n. 7
0
 public CommandMaker(ServerWorker worker)
 {
     this.worker = worker;
     this.pos    = 0;
     InitializeComponent();
 }
Esempio n. 8
0
 public FileSystem(ServerWorker worker)
 {
     this.worker = worker;
     InitializeComponent();
 }