Пример #1
0
        /// <summary>
        /// 初始化数据端口
        /// </summary>
        private void InitializeDataPorts()
        {
            isPortAvailable = SearchSparePort();
            for (int i = availablePorts.Count - 1; i >= 0; i--)
            {
                DataPort dport = new DataPort(ip, availablePorts.Dequeue());
                dport.portRecycle += PortRecycler;  //注册回收端口事件
                if (this.AcceptedDataPort != null)
                {
                    dport.AcceptedDataPort += this.AcceptedDataPort;
                }
                if (this.FileReceiveBegin != null)
                {
                    dport.FileReceiveBegin += this.FileReceiveBegin;
                }
                if (this.FileReceiveEnd != null)
                {
                    dport.FileReceiveEnd += this.FileReceiveEnd;
                }
                if (this.FileSendBegin != null)
                {
                    dport.FileSendBegin += this.FileSendBegin;
                }
                if (this.FileSendEnd != null)
                {
                    dport.FileSendEnd += this.FileSendEnd;
                }

                ports.Add(dport);
                PortQueue.Enqueue(dport);
            }
        }
Пример #2
0
 /// <summary>
 /// 回收数据端口
 /// </summary>
 /// <param name="port"></param>
 private void PortRecycler(DataPort port)
 {
     if (!PortQueue.Contains(port))
     {
         PortQueue.Enqueue(port);
     }
     ProvideClientService();
 }