Esempio n. 1
0
        private void registerAndResolve()
        {
            getPort();
            //将本应用使用的IP地址及端口号,注册到群中
            if (!MyPNRP.registerPeer(strpeerName))
            {
                MessageBox.Show("未开启点对点服务");
            }
            //定期解析对等点所在群的同名对等节点的信息
            Thread resolveThread = new Thread(Resolve);

            resolveThread.Start();
            resolveThread.IsBackground = true;
            Start_Receiving_Video_Conference();
        }
Esempio n. 2
0
        /// <summary>
        /// 解析名称
        /// </summary>
        private void Resolve()
        {
            while (!isExit)
            {
                PeerNameRecordCollection recColl = MyPNRP.ResolverPeer(strpeerName);
                resolvedListViewItem.Clear();

                foreach (PeerNameRecord record in recColl)
                {
                    foreach (IPEndPoint endP in record.EndPointCollection)
                    {
                        if (endP.AddressFamily.Equals(AddressFamily.InterNetwork))
                        {
                            ListViewItem item1 = new ListViewItem(endP.ToString());

                            resolvedListViewItem.Add(item1);
                        }
                    }
                }

                //检查是否有其他终端退出,如已经退出则从列表中删除该项
                if (resolvedListViewItem.Count == 0)
                {
                    ClearItems();
                }
                else
                {
                    RemoveItem();
                }

                foreach (PeerNameRecord record in recColl)
                {
                    foreach (IPEndPoint endP in record.EndPointCollection)
                    {
                        if (endP.AddressFamily.Equals(AddressFamily.InterNetwork))
                        {
                            ListViewItem item1 = new ListViewItem(endP.ToString());
                            AppendItem(item1);
                        }
                    }
                }
            }
        }