Example #1
0
        /// <summary>
        /// Event Fired when a Client gets connected. Following actions are performed
        /// 1. Update Tree view
        /// 2. Open a chat box to chat with client.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ClientAdded(object sender, EventArgs e)
        {
            tcpClient = ((MyEventArgs)e).clientSock;
            String remoteIP   = ((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address.ToString();
            String remotePort = ((IPEndPoint)tcpClient.Client.RemoteEndPoint).Port.ToString();

            // Call Delegate Function to update Tree View
            UpdateClientList(remoteIP + " : " + remotePort, "Add");

            // Show Dialog Box for Chatting
            ctd      = new ChatDialog(this, tcpClient);
            ctd.Text = "Connected to " + remoteIP + "on port number " + remotePort;

            // Add Dialog Box Object to Array List
            formArray.Add(ctd);
            threadArray.Add(Thread.CurrentThread);
            ctd.ShowDialog();
        }