public async Task <IDisposable> Receive <T>(SubscriptionConfiguration config, IObserver <T> observer) { var client = await _subscriptionClientFactory.CreateFor <T>(config); config.ConfigAction(client); Receive <T>(client, observer.OnNext, observer.OnError); return(new DisposableAction(() => Stop <T>(client))); }
public async Task <SubscriptionClient> CreateFor <T>(SubscriptionConfiguration config) { var subscription = await _subscriptionRepository.Get <T>(config.SubscriptionName); var topicPath = subscription.TopicPath; //TODO async return(_messagingFactory.CreateSubscriptionClient(topicPath, subscription.Name, config.ReceiveMode)); }
public IConfigurated Subscribe(IObserver <T> observer, SubscriptionConfiguration config) { //TODO: needs to be unique for multiple application use if (_observers.ContainsKey(config.SubscriptionName)) { throw new DuplicateNameException(config.SubscriptionName); } _observers[config.SubscriptionName] = observer; var stop = _messageReceiver.Receive(config, observer); return(new DisposableAction(() => Unhsubscribe(config.SubscriptionName, stop)) { Config = config }); }
public IDisposable Subscribe <T>(IObserver <T> handler, SubscriptionConfiguration configuration) { var observable = GetObservable <T>(); return(observable.Subscribe(handler, configuration)); }