Beispiel #1
0
        public bool UnsubscribeInput(InputSubscriptionRequest _subReq)
        {
            var subReq = _subReq.Clone();

            LogInputSubReq("UnsubscribeInput", subReq);
            var ret = false;

            if (ActiveInputSubscriptions.ContainsKey(subReq.SubscriptionDescriptor.SubscriberGuid))
            {
                var provider = GetProvider <IInputProvider>(subReq.ProviderDescriptor.ProviderName);
                ret = provider.UnsubscribeInput(ActiveInputSubscriptions[subReq.SubscriptionDescriptor.SubscriberGuid]);
                if (ret)
                {
                    ActiveInputSubscriptions.Remove(subReq.SubscriptionDescriptor.SubscriberGuid);
                }
            }
            return(ret);
        }
Beispiel #2
0
        public bool SubscribeInput(InputSubscriptionRequest _subReq)
        {
            // Clone subreq before passing to provider, so if it gets altered outside, it does not affect the copy
            var subReq = _subReq.Clone();

            LogInputSubReq("SubscribeInput", subReq);
            if (ActiveInputSubscriptions.ContainsKey(subReq.SubscriptionDescriptor.SubscriberGuid))
            {
                // If this Subscriber has an existing subscription...
                // ... then remove the old subscription first.
                Log("Existing subscription found, removing...");
                var oldSub = ActiveInputSubscriptions[subReq.SubscriptionDescriptor.SubscriberGuid];
                UnsubscribeInput(oldSub);
            }
            var provider = GetProvider <IInputProvider>(subReq.ProviderDescriptor.ProviderName);
            var ret      = provider.SubscribeInput(subReq);

            if (ret)
            {
                ActiveInputSubscriptions.Add(subReq.SubscriptionDescriptor.SubscriberGuid, subReq);
            }
            return(ret);
        }