/// <summary>
        /// Subscribes to the observable using the given observer.
        /// </summary>
        /// <param name="observer">Observer to send the observable's data to.</param>
        /// <param name="subscriptionUri">URI to identify the subscription.</param>
        /// <param name="state">Additional metadata to associate with the artifact. Implementations can interpret this value, or ignore it.</param>
        /// <returns>Subscription object that can be used to cancel the subscription, or an exception if the submission was unsuccessful.</returns>
        public IReactiveSubscription Subscribe(IReactiveObserver <T> observer, Uri subscriptionUri, object state = null)
        {
            if (observer == null)
            {
                throw new ArgumentNullException(nameof(observer));
            }
            if (subscriptionUri == null)
            {
                throw new ArgumentNullException(nameof(subscriptionUri));
            }

            return(SubscribeCore(observer, subscriptionUri, state));
        }
        /// <summary>
        /// Subscribes to the observable using the given observer.
        /// </summary>
        /// <param name="observer">Observer to send the observable's data to.</param>
        /// <param name="subscriptionUri">URI to identify the subscription.</param>
        /// <param name="state">Additional metadata to associate with the artifact. Implementations can interpret this value, or ignore it.</param>
        /// <returns>A subscription object that can be used to cancel the subscription, or an exception if the submission was unsuccessful.</returns>
        protected override IReactiveSubscription SubscribeCore(IReactiveObserver <T> observer, Uri subscriptionUri, object state)
        {
            if (observer is IExpressible expressible)
            {
                var qbserver     = Provider.CreateQbserver <T>(expressible.Expression);
                var qubscription = SubscribeCore(qbserver, subscriptionUri, state);
                return(qubscription);
            }

            //
            // NB: A sophisticated client could support this by creating a "reverse proxy" stream in the service and
            //     create a channel to ship events from the stream to the local observer instance. However, it does
            //     require more than this in order to deal with client disconnects and cleanup of service-side resources
            //     or support some form of client-side recovery to reassociate an observer instance to an existing
            //     query (given its subscription URI).
            //

            throw new NotSupportedException("Local observer cannot be subscribed to a remote observable.");
        }
Example #3
0
 protected override IReactiveSubscription SubscribeCore(IReactiveObserver <T> observer, Uri subscriptionUri, object state)
 {
     return(SubscribeImpl(observer, subscriptionUri, state));
 }
Example #4
0
 public IReactiveSubscription Subscribe(IReactiveObserver <T> observer, Uri subscriptionUri, object state)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Subscribes to the observable using the given observer.
 /// </summary>
 /// <param name="observer">Observer to send the observable's data to.</param>
 /// <param name="subscriptionUri">URI to identify the subscription.</param>
 /// <param name="state">Additional metadata to associate with the artifact. Implementations can interpret this value, or ignore it.</param>
 /// <returns>Subscription object that can be used to cancel the subscription, or an exception if the submission was unsuccessful.</returns>
 protected abstract IReactiveSubscription SubscribeCore(IReactiveObserver <T> observer, Uri subscriptionUri, object state);