private void addClient(PacketHeader packetHeader, Connection connection, clientInfo incomingObject)
        {
            clientInfoServ toAdd = new clientInfoServ(incomingObject.name, connection);

            //MessageBox.Show("Name: " + incomingObject.name);
            addUser(toAdd);
            try
            {
                TCPConnection.GetConnection(connection.ConnectionInfo).SendObject("ClientInfo", chost);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void addUser(clientInfoServ user)
        {
            clientList.Add(user);

            Users.Invoke(new MethodInvoker(delegate()
            {
                Users.Items.Add(user.name);
            }));

            Rank.Invoke(new MethodInvoker(delegate()
            {
                Rank.Items.Add(user.rank);
            }));


            NotifyServer(user.conn, user.name + " has connected.");
        }
        //server
        public ChatForm(int port)
        {
            clientList = new ArrayList();
            InitializeComponent();

            this.port = port;
            this.ip   = "192.168.1.123";
            isHost    = true;

            // [ttaj] Setup the server, if the object being sent is a string then run the function PrintIncMsg
            NetworkComms.AppendGlobalIncomingPacketHandler <clientInfo>("ClientInfo", addClient);
            NetworkComms.AppendGlobalIncomingPacketHandler <messageHolder>("Message", addMessage);

            // [ttaj] Start the server.
            TCPConnection.StartListening(ConnectionType.TCP, new System.Net.IPEndPoint(IPAddress.Parse(ip), port));
            host  = new clientInfoServ("Host", null, "H");
            chost = new clientInfo("Host", "H");
            ChatLog.Items.Add("Server successfully started!");

            clientList.Add(host);
            Users.Items.Add(host.name);
            Rank.Items.Add(host.rank);
        }