public DefaultConnector(IChannelFactory channelFactory, IdleStateMonitor idleStateMonitor, IHandshakeHandler handshakeHandler)
 {
     this.channel          = channelFactory.CreateChannel();
     this.handshakeHandler = handshakeHandler;
     this.idleStateMonitor = idleStateMonitor ?? new IdleStateMonitor(TimeSpan.FromSeconds(30.0));
     this.idleStateMonitor.IdleStateChanged += OnIdleStateChanged;
 }
 public DefaultConnector(IChannel <IMessage> channel, IdleStateMonitor idleStateMonitor, IHandshakeHandler handshakeHandler)
 {
     this.channel          = channel ?? throw new ArgumentNullException(nameof(channel));
     this.handshakeHandler = handshakeHandler;
     this.idleStateMonitor = idleStateMonitor ?? new IdleStateMonitor(TimeSpan.FromSeconds(30.0));
     this.idleStateMonitor.IdleStateChanged += OnIdleStateChanged;
 }
#pragma warning disable 4014
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (running)
                {
                    try
                    {
                        this.running = false;
                        lock (stateLock)
                        {
                            Monitor.PulseAll(stateLock);
                        }

                        if (this.channel != null)
                        {
                            this.State = ConnectionState.Closing;
                            DoDisconnect();
                            this.channel = null;
                        }

                        if (idleStateMonitor != null)
                        {
                            idleStateMonitor.IdleStateChanged -= OnIdleStateChanged;
                            idleStateMonitor.Dispose();
                            idleStateMonitor = null;
                        }

                        this.eventArgsSubject.Dispose();
                        this.notificationSubject.Dispose();
                        foreach (var kv in promises)
                        {
                            var promise = kv.Value;
                            promise.SetCanceled();
                        }
                        this.promises.Clear();
                    }
                    finally
                    {
                        this.State = ConnectionState.Closed;
                    }
                }
                disposedValue = true;
            }
        }
#pragma warning disable 4014
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (this.shutdownTokenSource != null)
                {
                    try
                    {
                        shutdownTokenSource.Cancel();
                        this.shutdownTokenSource = null;

                        if (this.channel != null)
                        {
                            this.State = ConnectionState.Closing;
                            DoDisconnect();
                            this.channel = null;
                        }

                        if (idleStateMonitor != null)
                        {
                            idleStateMonitor.IdleStateChanged -= OnIdleStateChanged;
                            idleStateMonitor.Dispose();
                            idleStateMonitor = null;
                        }

                        this.eventArgsSubject.Dispose();
                        this.notificationSubject.Dispose();
                        foreach (var kv in promises)
                        {
                            var promise = kv.Value;
                            promise.SetCanceled();
                        }
                        this.promises.Clear();
                    }
                    finally
                    {
                        this.State = ConnectionState.Closed;
                    }
                }
                disposedValue = true;
            }
        }
Beispiel #5
0
 public DefaultConnector(IChannel <IMessage> channel, IdleStateMonitor idleStateMonitor)
 {
     this.channel          = channel ?? throw new ArgumentNullException("channel");
     this.idleStateMonitor = idleStateMonitor ?? new IdleStateMonitor(TimeSpan.FromSeconds(30.0));
     this.idleStateMonitor.IdleStateChanged += OnIdleStateChanged;
 }
 public DefaultConnector(IChannelFactory channelFactory, IdleStateMonitor idleStateMonitor) : this(channelFactory, idleStateMonitor, null)
 {
 }
 public DefaultConnector(IChannel <IMessage> channel, IdleStateMonitor idleStateMonitor) : this(channel, idleStateMonitor, null)
 {
 }