public SubscriptionObservable(ILogger <ManagedObservable <T> > logger,
                                      ISubscriptionFactory <T> subscriptionFactory) : base(logger)
        {
            if (subscriptionFactory == null)
            {
                throw new ArgumentNullException(nameof(subscriptionFactory));
            }

            _subscriptionClient = subscriptionFactory.Create();
            _subscriptionClient.RegisterCallback(Notify);
        }
예제 #2
0
        private ISubscription Subscribe <TMessage>(Action <TMessage, IDeliveryContext> onMessage, ISubscriptionConfiguration subscriptionConfiguration)
        {
            logger.DebugFormat("Subscribing to action callback of type {0}", typeof(TMessage).Name);

            var subscription = subscriptionFactory.Create(
                this,
                subscriptionConfiguration,
                onMessage);

            if (subscription.IsStartable)
            {
                subscription.Start();
            }
            else
            {
                logger.InfoFormat("Could not start subscription, invalid configuration: {0}", subscription);
            }

            return(subscription);
        }
예제 #3
0
 private Subscription Map(SubscriptionRecord rec) => factory.Create(rec.Id, rec.UserId, rec.SpaceId);