Beispiel #1
0
        public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, string clientProvidedName = null)
        {
            ClientProvidedName = clientProvidedName;
            KnownHosts         = null;
            FrameMax           = 0;
            m_factory          = factory;
            m_frameHandler     = frameHandler;

            var asyncConnectionFactory = factory as IAsyncConnectionFactory;

            if (asyncConnectionFactory != null && asyncConnectionFactory.DispatchConsumersAsync)
            {
                ConsumerWorkService = new AsyncConsumerWorkService();
            }
            else
            {
                ConsumerWorkService = new ConsumerWorkService();
            }

            m_sessionManager = new SessionManager(this, 0);
            m_session0       = new MainSession(this)
            {
                Handler = NotifyReceivedCloseOk
            };
            m_model0 = (ModelBase)Protocol.CreateModel(m_session0);

            StartMainLoop(factory.UseBackgroundThreadsForIO);
            Open(insist);
        }
Beispiel #2
0
        public Connection(IConnectionFactory factory, IFrameHandler frameHandler, string clientProvidedName = null)
        {
            ClientProvidedName = clientProvidedName;
            _factory           = factory;
            _frameHandler      = frameHandler;

            ConsumerWorkService = factory.DispatchConsumersAsync
                ? new AsyncConsumerWorkService(factory.ConsumerDispatchConcurrency)
                : new ConsumerWorkService(factory.ConsumerDispatchConcurrency);

            Action <Exception, string> onException = (exception, context) => OnCallbackException(CallbackExceptionEventArgs.Build(exception, context));

            _callbackExceptionWrapper   = new EventingWrapper <CallbackExceptionEventArgs>(string.Empty, (exception, context) => { });
            _connectionBlockedWrapper   = new EventingWrapper <ConnectionBlockedEventArgs>("OnConnectionBlocked", onException);
            _connectionUnblockedWrapper = new EventingWrapper <EventArgs>("OnConnectionUnblocked", onException);
            _connectionShutdownWrapper  = new EventingWrapper <ShutdownEventArgs>("OnShutdown", onException);

            _sessionManager = new SessionManager(this, 0);
            _session0       = new MainSession(this)
            {
                Handler = NotifyReceivedCloseOk
            };
            _model0 = (ModelBase)Protocol.CreateModel(_session0);

            StartMainLoop();
            Open();
        }
        public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, string clientProvidedName = null)
        {
            this.ClientProvidedName = clientProvidedName;
            KnownHosts               = null;
            FrameMax                 = 0;
            m_factory                = factory;
            m_frameHandler           = frameHandler;
            this.ConsumerWorkService = new ConsumerWorkService(factory.TaskScheduler);

            m_sessionManager = new SessionManager(this, 0);
            m_session0       = new MainSession(this)
            {
                Handler = NotifyReceivedCloseOk
            };
            m_model0 = (ModelBase)Protocol.CreateModel(m_session0);

            StartMainLoop(factory.UseBackgroundThreadsForIO);
            Open(insist);

#if NETFX_CORE
#pragma warning disable 0168
            try
            {
                Windows.UI.Xaml.Application.Current.Suspending += this.HandleApplicationSuspend;
            }
            catch (Exception ex)
            {
                // If called from a desktop app (i.e. unit tests), then there is no current application
            }
#pragma warning restore 0168
#else
            AppDomain.CurrentDomain.DomainUnload += HandleDomainUnload;
#endif
        }
 public ConcurrentConsumerDispatcher(ModelBase model, ConsumerWorkService ws)
 {
     this.model = model;
     this.workService = ws;
     this.workService.RegisterKey(model);
     this.IsShutdown = false;
 }
Beispiel #5
0
        public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, string clientProvidedName = null)
        {
            ClientProvidedName = clientProvidedName;
            KnownHosts         = null;
            FrameMax           = 0;
            _factory           = factory;
            _frameHandler      = frameHandler;

            if (factory is IAsyncConnectionFactory asyncConnectionFactory && asyncConnectionFactory.DispatchConsumersAsync)
            {
                ConsumerWorkService = new AsyncConsumerWorkService(factory.ConsumerDispatchConcurrency);
            }
        public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, string clientProvidedName = null)
        {
            this.ClientProvidedName = clientProvidedName;
            KnownHosts               = null;
            FrameMax                 = 0;
            m_factory                = factory;
            m_frameHandler           = frameHandler;
            this.ConsumerWorkService = new ConsumerWorkService(factory.TaskScheduler);

            m_sessionManager = new SessionManager(this, 0);
            m_session0       = new MainSession(this)
            {
                Handler = NotifyReceivedCloseOk
            };
            m_model0 = (ModelBase)Protocol.CreateModel(m_session0);

            StartMainLoop(factory.UseBackgroundThreadsForIO);
            Open(insist);
        }
        public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler)
        {
            KnownHosts               = null;
            FrameMax                 = 0;
            m_factory                = factory;
            m_frameHandler           = frameHandler;
            this.ConsumerWorkService = new ConsumerWorkService(factory.TaskScheduler);

            m_sessionManager = new SessionManager(this, 0);
            m_session0       = new MainSession(this)
            {
                Handler = NotifyReceivedCloseOk
            };
            m_model0 = (ModelBase)Protocol.CreateModel(m_session0);

            StartMainLoop(factory.UseBackgroundThreadsForIO);
            Open(insist);
            StartHeartbeatTimers();
            AppDomain.CurrentDomain.DomainUnload += HandleDomainUnload;
        }
        public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, string clientProvidedName = null)
        {
            ClientProvidedName = clientProvidedName;
            KnownHosts         = null;
            FrameMax           = 0;
            _factory           = factory;
            _frameHandler      = frameHandler;

            ConsumerWorkService = factory.DispatchConsumersAsync
                ? new AsyncConsumerWorkService(factory.ConsumerDispatchConcurrency)
                : new ConsumerWorkService(factory.ConsumerDispatchConcurrency);

            _sessionManager = new SessionManager(this, 0);
            _session0       = new MainSession(this)
            {
                Handler = NotifyReceivedCloseOk
            };
            _model0 = (ModelBase)Protocol.CreateModel(_session0);

            StartMainLoop();
            Open(insist);
        }
Beispiel #9
0
 public IModel CreateModel(ISession session, ConsumerWorkService workService)
 {
     return(new Model(session, workService));
 }
Beispiel #10
0
 public Model(ISession session, ConsumerWorkService workService)
     : base(session, workService)
 {
 }
        public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler, string clientProvidedName = null)
        {
            ClientProvidedName = clientProvidedName;
            KnownHosts = null;
            FrameMax = 0;
            m_factory = factory;
            m_frameHandler = frameHandler;
            ConsumerWorkService = new ConsumerWorkService();

            m_sessionManager = new SessionManager(this, 0);
            m_session0 = new MainSession(this) { Handler = NotifyReceivedCloseOk };
            m_model0 = (ModelBase)Protocol.CreateModel(m_session0);

            StartMainLoop(factory.UseBackgroundThreadsForIO);
            Open(insist);
        }
 public ModelBase(ISession session, ConsumerWorkService workService)
 {
     ConsumerDispatcher = new ConcurrentConsumerDispatcher(this, workService);
     Initialise(session);
 }
 public IModel CreateModel(ISession session, ConsumerWorkService workService)
 {
     return new Model(session, workService);
 }
        public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHandler)
        {
            KnownHosts = null;
            FrameMax = 0;
            m_factory = factory;
            m_frameHandler = frameHandler;
            this.ConsumerWorkService = new ConsumerWorkService(factory.TaskScheduler);

            m_sessionManager = new SessionManager(this, 0);
            m_session0 = new MainSession(this) { Handler = NotifyReceivedCloseOk };
            m_model0 = (ModelBase)Protocol.CreateModel(m_session0);

            StartMainLoop(factory.UseBackgroundThreadsForIO);
            Open(insist);

#if NETFX_CORE
#pragma warning disable 0168
            try
            {
                Windows.UI.Xaml.Application.Current.Suspending += this.HandleApplicationSuspend;
            }
            catch (Exception ex)
            {
                // If called from a desktop app (i.e. unit tests), then there is no current application
            }
#pragma warning restore 0168
#else
            AppDomain.CurrentDomain.DomainUnload += HandleDomainUnload;
#endif
        }