示例#1
0
        private void RegisterProxy(ChannelWrapper channelWrapper)
        {
            if (channel != null)
            {
                channel.Dispose();
            }

            channel = channelWrapper;
#if DEBUG
            channel.Closing += (o, e) => LogManager.GetCurrentClassLogger().Debug("channel closing");
            channel.Closed  += (o, e) => LogManager.GetCurrentClassLogger().Debug("channel closed");
            channel.Faulted += (o, e) => LogManager.GetCurrentClassLogger().Debug("channel faulted");
            channel.Opened  += (o, e) => LogManager.GetCurrentClassLogger().Debug("channel opened");
            channel.Opening += (o, e) => LogManager.GetCurrentClassLogger().Debug("channel opening");
#endif
            channel.PeerNode.MessagePropagationFilter = new RemoteOnlyMessagePropagationFilter();
            channel.Online += PeerNodeOnline;
            channel.Online += PeerNodeOffline;
        }
        public void Dispose()
        {
            if (disposed)
            {
                return;
            }

            if (channel != null)
            {
                channel.Dispose();
                channel = null;
            }

            if (channelFactory != null)
            {
                channelFactory.Close();
                channelFactory = null;
            }

            DisposeCallbackIfNeed();

            GC.SuppressFinalize(this);
            disposed = true;
        }