示例#1
0
 public void KeepListening()
 {
     while (listening)
     {
         var tcpClient = listener.AcceptTcpClient();
         DirectConnection connection = new DirectConnection(tcpClient, this);
         AddChatTab(connection);
     }
 }
示例#2
0
        private void StartDirectConnection(string address)
        {
            var parameters = address.Split(":");
            var ipAddress  = IPAddress.Parse(parameters[0]);
            var hostPort   = int.Parse(parameters[1]);
            var userName   = parameters[2];
            var tcpContact = new TcpClient();

            tcpContact.Connect(ipAddress, hostPort);
            var connection = new DirectConnection(tcpContact, userName, this);

            connection.SendToClient(MsgCode.Standard, UserName);
            AddChatTab(connection);
        }
示例#3
0
        private void AddChatTab(DirectConnection contact)
        {
            try
            {
                var page = new TabPage();
                page.Text = contact.UserName;

                var tbx = new TextBox();
                tbx.Parent    = page;
                tbx.Multiline = true;
                tbx.Location  = new Point(0, 0);
                tbx.Size      = tabGlobal.Size;

                contact.Page = page;
                contact.Chat = tbx;

                Invoke((Action)(() => tabControl.TabPages.Add(page)));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }