Example #1
0
        /// <summary>
        /// 移除指定的通讯接口
        /// </summary>
        /// <param name="handler">将要移除的通讯接口。</param>
        public void RemoveCommHandler(IRsspNode handler)
        {
            if (_commList != null)
            {
                if (_commList.Contains(handler))
                {
                    handler.TcpEndPointListening    -= OnTcpEndPointListening;
                    handler.TcpEndPointListenFailed -= OnTcpEndPointListenFailed;

                    handler.TcpConnecting    -= OnTcpConnecting;
                    handler.TcpConnected     -= OnTcpConnected;
                    handler.TcpConnectFailed -= OnTcpConnectFailed;
                    handler.TcpDisconnected  -= OnTcpDisconnected;

                    handler.NodeConnected    -= OnNodeConnected;
                    handler.NodeDisconnected -= OnNodeInterruption;

                    handler.UserDataIncoming -= OnUserDataIncoming;
                    handler.UserDataOutgoing -= OnUserDataOutgoing;

                    handler.IncomingCacheCountChanged -= OnIncomingCacheCountChanged;
                    handler.OutgoingCacheCountChanged -= OnOutgoingCacheCountChanged;

                    _commList.Remove(handler);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 添加通讯接口
        /// </summary>
        /// <param name="handler"></param>
        public void AddCommHandler(IRsspNode handler)
        {
            if (handler != null)
            {
                if (!_commList.Contains(handler))
                {
                    _commList.Add(handler);

                    handler.TcpEndPointListening    += OnTcpEndPointListening;
                    handler.TcpEndPointListenFailed += OnTcpEndPointListenFailed;

                    handler.TcpConnecting    += OnTcpConnecting;
                    handler.TcpConnected     += OnTcpConnected;
                    handler.TcpConnectFailed += OnTcpConnectFailed;
                    handler.TcpDisconnected  += OnTcpDisconnected;

                    handler.NodeConnected    += OnNodeConnected;
                    handler.NodeDisconnected += OnNodeInterruption;

                    handler.UserDataIncoming += OnUserDataIncoming;
                    handler.UserDataOutgoing += OnUserDataOutgoing;

                    handler.IncomingCacheCountChanged += OnIncomingCacheCountChanged;
                    handler.OutgoingCacheCountChanged += OnOutgoingCacheCountChanged;
                }
            }
        }
Example #3
0
        private void CloseResource()
        {
            try
            {
                _dataSendingControl.StopSending();

                if (_rsspNodeComm != null)
                {
                    _rsspNodeComm.Dispose();
                    _rsspNodeComm.LogCreated       -= OnRsspCommLogCreated;
                    _rsspNodeComm.UserDataIncoming -= this.OnUserDataIncoming;
                }

                _commMonitorControl.ClearCommHandler();

                _fileManager.Clear();
            }
            catch (System.Exception ex)
            {
                LogUtility.Error(ex);
            }
            finally
            {
                _rsspNodeComm = null;
            }
        }
Example #4
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            try
            {
                if (_rsspNodeComm != null)
                {
                    throw new ApplicationException("通信接口已经处于打开状态。");
                }

                // Create
                _rsspNodeComm                   = _commFactory.Create();
                _rsspNodeComm.LogCreated       += OnRsspCommLogCreated;
                _rsspNodeComm.UserDataIncoming += this.OnUserDataIncoming;

                _commMonitorControl.ClearCommHandler();
                _commMonitorControl.AddCommHandler(_rsspNodeComm);

                // Open
                _rsspNodeComm.Open();

                // 设置数据发送控件
                _dataSendingControl.NodeComm = _rsspNodeComm;
                _snapshotControl.CommNode    = _rsspNodeComm;

                // 更新界面
                _settingPage.UpdateControl(true);

                //
                btnOpen.Enabled = false;
            }
            catch (System.Exception ex)
            {
                _settingPage.UpdateControl(false);
                btnOpen.Enabled = true;

                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }