Beispiel #1
0
        public static void DisconnectClients()
        {
            foreach (var subscriber in Subscribers)
            {
                subscriber.Disconnect();
            }

            Subscribers.Clear();
        }
Beispiel #2
0
        public void Dispose()
        {
            Logger.Debug("EventHub is disposing...");

            Timer.Stop();
            Timer.Elapsed -= OnHandleEventMessages;
            Timer          = null;

            Subscribers.Clear();
            Subscribers = null;

            Logger.Debug("EventHub disposes completely.");
        }
Beispiel #3
0
        internal static void Reset()
        {
            Logger.Debug("Resetting publisner: clearing queue and removing all subscribers");
            lock (PublishReadingLock)
            {
                Readings = new ConcurrentQueue <Reading>();
            }

            lock (AddSubscriberLock)
            {
                Subscribers.Clear();
            }
        }
Beispiel #4
0
        //---------------------------------------------------------------------
        public override Task OnDeactivateAsync()
        {
            TimerHandleUpdate.Dispose();
            TimerHandleSave.Dispose();

            if (EtPlayer != null)
            {
                EtPlayer.close();
                EtPlayer = null;
            }

            Subscribers.Clear();

            Logger.Info("OnDeactivateAsync()");

            return(base.OnDeactivateAsync());
        }
        protected void DetachEvents()
        {
            if (IsDestroying || IsDisabling)
            {
                return;
            }

            IsDestroying = true;

            if (EventIdentifiers != null)
            {
                foreach (var id in EventIdentifiers)
                {
                    EventHub.Off(id);
                }

                EventIdentifiers.Clear();
            }

            // Detach observed components
            if (ObservedComponents != null)
            {
                foreach (var component in ObservedComponents)
                {
                    component.Off(this);
                }

                ObservedComponents.Clear();
            }

            // Detach subscribers
            if (Subscribers != null)
            {
                foreach (var subscriber in Subscribers)
                {
                    subscriber.Key.Disconnect(this);
                    subscriber.Value.Clear();
                }

                Subscribers.Clear();
            }

            //foreach (var e in GetType().GetEvents()) {
            //    e.ClearEvents(this);
            //}
        }
Beispiel #6
0
 /// <summary>
 /// Unsubscribe to all notification keys.
 /// </summary>
 public static void UnsubscribeAll()
 {
     Subscribers?.Clear();
     SubscribersWithData?.Clear();
 }
Beispiel #7
0
 public void Dispose()
 {
     IsLooking = false;
     Subscribers.Clear();
     _listener.Stop();
 }