Exemple #1
0
        public bool Unsubscribe(IIOClientChannel channel)
        {
            IOEventSubscription subscription;

            if (!eventSubscriptions.TryRemove(channel, out subscription))
            {
                return(false);
            }

            OnUnsubscribed(new IOEventSubscriberEventArgs(subscription));
            subscription.Dispose();
            return(true);
        }
Exemple #2
0
 private IDisposable Subscribe(int id, IObservable <object> observable, IIOClientChannel channel)
 {
     return(observable.ObserveOn(TaskPoolScheduler.Default).Subscribe(value =>
     {
         try
         {
             channel.Update(id, value);
         }
         catch
         {
             Unsubscribe(channel);
         }
     }));
 }
Exemple #3
0
        public void Subscribe(IIOClientChannel channel, string name)
        {
            var subscription = new IOEventSubscription(name);

            foreach (var channelSubject in channelSubjects)
            {
                int id = channelSubject.Key;
                subscription.Handles.Add(Subscribe(id, channelSubject.Value, channel));
            }
            eventSubscriptions.AddOrUpdate(channel, subscription, (c, s) =>
            {
                s.Dispose();
                return(subscription);
            });
            OnSubscribed(new IOEventSubscriberEventArgs(subscription));
        }