Inheritance: System.Windows.Forms.Form
 public FileServer(administrate _owner, string _expectedIP, int _port, string _locationToSave, string _locToReadFrom)
 {
     // Internalizing the variables
     expectedIP     = _expectedIP;
     port           = _port;
     locationToSave = _locationToSave;
     owner          = _owner;
     locToReadFrom  = _locToReadFrom;
 }
 public FileServer(administrate _owner, string _expectedIP, int _port, string _locationToSave, string _locToReadFrom)
 {
     // Internalizing the variables
     expectedIP = _expectedIP;
     port = _port;
     locationToSave = _locationToSave;
     owner = _owner;
     locToReadFrom = _locToReadFrom;
 }
 private void lbClients_DoubleClick(object sender, EventArgs e)
 {
     if (lbClients.SelectedItems.Count == 1)
     {
         administrate admin = new administrate(lbClients.SelectedItems[0].SubItems[0].Text,
                                               commonData.ns_collection[lbClients.SelectedItems[0].Index], lbClients.SelectedItems[0].SubItems[2].Text);
         admin.Show();
         commonData.ip_panel_pair.Add(lbClients.SelectedItems[0].SubItems[2].Text, admin);
     }
 }
        private void removeFromList(string ip)
        {
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker) delegate { removeFromList(ip); });
            }
            else
            {
                for (int i = 0; i < lbClients.Items.Count; i++)
                {
                    if (lbClients.Items[i].SubItems[2].Text == ip)
                    {
                        administrate panel = GetAssosicatedPanel(lbClients.Items[i].SubItems[2].Text);
                        lbClients.Items.RemoveAt(i);

                        if (panel != null)
                        {
                            panel.Intermission();
                        }
                        break;
                    }
                }
            }
        }
        private void HandleClientComm(object client)
        {
            // Getting the dataStream
            TcpClient     tcpClient    = (TcpClient)client;
            NetworkStream clientStream = tcpClient.GetStream();

            string whoami     = StripIP(tcpClient.Client.RemoteEndPoint.ToString());
            string given_name = "to-be-determined";
            string os_data    = "to-be-determined";

            // Custom variables
            byte[] incoming_raw_data = new byte[2048];
            int    bytesRead;
            bool   disconnect = false;
            int    session    = 0;

            while (!disconnect)
            {
                bytesRead = 0;

                try
                {
                    bytesRead = clientStream.Read(incoming_raw_data, 0, 2048);
                }
                catch
                {
                    #region Disconnection Routine + return directive
                    DisconnectionRoutine(whoami, ref tcpClient, ref clientStream);
                    return;

                    #endregion
                }

                if (bytesRead == 0)
                {
                    #region Disconnection Routine + return directive
                    DisconnectionRoutine(whoami, ref tcpClient, ref clientStream);
                    return;

                    #endregion
                }

                if (CheckValidity(ref incoming_raw_data) == false)
                {
                    if (session > 0) // We have an amorphous package! We should celebrate it!
                    {
                        administrate activePanel = GetAssosicatedPanel(whoami);
                        if (activePanel != null) // Panel is open
                        {
                            // Passing the communication over to the associated admin panel.
                            activePanel.reportAmorphPack(incoming_raw_data, bytesRead);
                        }
                        continue;
                    }
                    else
                    {
                        #region Disconnection Routine + return directive
                        DisconnectionRoutine(whoami, ref tcpClient, ref clientStream);
                        return;

                        #endregion
                    }
                }


                // -- We got a valid raw data - proceeding
                // -- Be careful to start reading the package from [scheme.Length]

                // CLIENT IS IDENTIFYING ITSELF
                if (incoming_raw_data[commonData.scheme.Length] == 10)
                {
                    // A client can't identify itself twice
                    if (session != 0)
                    {
                        #region Disconnection Routine + return directive
                        DisconnectionRoutine(whoami, ref tcpClient, ref clientStream);
                        return;

                        #endregion
                    }

                    // Interpreting the rest as ASCII
                    string[] nameAndOS = Regex.Split(encoder.GetString(incoming_raw_data, commonData.scheme.Length + 1, bytesRead - commonData.scheme.Length - 1), "<%SEP%>");

                    if (nameAndOS.Length != 2)
                    {
                        #region Disconnection Routine + return directive
                        DisconnectionRoutine(whoami, ref tcpClient, ref clientStream);
                        return;

                        #endregion
                    }

                    given_name = nameAndOS[0];
                    os_data    = nameAndOS[1];

                    // Adding the client to the common storage and the list
                    commonData.ns_collection.Add(clientStream);
                    addToList(given_name, os_data, whoami);

                    try
                    {
                        clientStream.Write(commonData.recv_signal, 0, commonData.recv_signal.Length);
                    }
                    catch { }
                }
                // GENERAL INFORMATION CHANNEL
                else if (incoming_raw_data[commonData.scheme.Length] == 20)
                {
                    // Identification is a must before conducting any further communication
                    if (session == 0)
                    {
                        #region Disconnection Routine + return directive
                        DisconnectionRoutine(whoami, ref tcpClient, ref clientStream);
                        return;

                        #endregion
                    }

                    administrate activePanel = GetAssosicatedPanel(whoami);
                    if (activePanel != null) // Panel is open
                    {
                        // Passing the communication over to the associated admin panel.
                        activePanel.reportIncomingComm(incoming_raw_data, bytesRead);
                    }
                }
                else
                {
                    #region Disconnection Routine + return directive
                    DisconnectionRoutine(whoami, ref tcpClient, ref clientStream);
                    return;

                    #endregion
                }

                session++;
            }
        }
 private void lbClients_DoubleClick(object sender, EventArgs e)
 {
     if (lbClients.SelectedItems.Count == 1)
     {
         administrate admin = new administrate(lbClients.SelectedItems[0].SubItems[0].Text,
             commonData.ns_collection[lbClients.SelectedItems[0].Index], lbClients.SelectedItems[0].SubItems[2].Text);
         admin.Show();
         commonData.ip_panel_pair.Add(lbClients.SelectedItems[0].SubItems[2].Text, admin);
     }
 }
 public FileUploadDisplay(administrate _owner, string remotePosition)
 {
     InitializeComponent();
     txtDestination.Text = remotePosition;
     owner = _owner;
 }
 public FileUploadDisplay(administrate _owner, string remotePosition)
 {
     InitializeComponent();
     txtDestination.Text = remotePosition;
     owner = _owner;
 }