Esempio n. 1
0
 protected override void OnRemoveBehavior()
 {
     if (EventProcessor != null)
     {
         EventProcessor.DetachEvents();
         EventProcessor.Dispose();
         EventProcessor = null;
     }
 }
Esempio n. 2
0
 /// <summary>Releases unmanaged and, optionally, managed resources.</summary>
 public void Dispose()
 {
     PlayerManager.Instance.GlobalPlayerLogInEvent  -= ProcessPlayerLogInEvent;
     PlayerManager.Instance.GlobalPlayerLogOutEvent -= ProcessPlayerLogOutEvent;
     if (EventProcessor != null)
     {
         EventProcessor.Dispose();
         EventProcessor = null;
     }
 }
 public void Dispose() => _eventProcessor.Dispose();
Esempio n. 4
0
        public EventProcessor CreateEventProcessor(string subscription, IEventHandler handler, ITextSerializer serializer, ILogger <IProcessor> logger)
        {
            if (!this.initialized)
            {
                throw new InvalidOperationException("Service bus configuration has not been initialized.");
            }

            TopicSettings        topicSettings        = null;
            SubscriptionSettings subscriptionSettings = null;

            foreach (var settings in this.settings.Topics.Where(t => t.IsEventBus))
            {
                subscriptionSettings = settings.Subscriptions.Find(s => s.Name == subscription);
                if (subscriptionSettings != null)
                {
                    topicSettings = settings;
                    break;
                }
            }

            if (subscriptionSettings == null)
            {
                throw new ArgumentOutOfRangeException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              "Subscription '{0}' has not been registered for an event bus topic in the service bus configuration.",
                              subscription));
            }

            IMessageReceiver receiver;

            if (subscriptionSettings.RequiresSession)
            {
                //var instrumentation = new SessionSubscriptionReceiverInstrumentation(subscription, instrumentationEnabled);
                try
                {
                    receiver = (IMessageReceiver) new SessionSubscriptionReceiver(this.settings, topicSettings.Path, subscription, true, factory.CreateLogger <SessionSubscriptionReceiver>());//instrumentation);
                }
                catch
                {
                    //instrumentation.Dispose();
                    throw;
                }
            }
            else
            {
                //var instrumentation = new SubscriptionReceiverInstrumentation(subscription, instrumentationEnabled);
                try
                {
                    receiver = (IMessageReceiver) new SubscriptionReceiver(this.settings, topicSettings.Path, subscription, true, factory.CreateLogger <SubscriptionReceiver>());//instrumentation);
                }
                catch
                {
                    //    instrumentation.Dispose();
                    throw;
                }
            }

            EventProcessor processor;

            try
            {
                processor = new EventProcessor(receiver, serializer, logger);
            }
            catch
            {
                using (receiver as IDisposable) { }
                throw;
            }

            try
            {
                processor.Register(handler);

                return(processor);
            }
            catch
            {
                processor.Dispose();
                throw;
            }
        }