/// <summary> /// creates a new instance of the rxn manager /// </summary> /// <param name="channel">the channel that will back the rxn sink</param> /// <param name="postman"></param> /// <param name="subscription"></param> public RxnManager(IRxnBackingChannel <T> channel, IDeliveryScheme <T> postman = null, IScheduler subscription = null) { DefaultScheduler = subscription ?? TaskPoolScheduler.Default; _postman = postman ?? new NoGaretenee <T>(); _channel = channel; Errors.Subscribe(this, error => { OnWarning("Backing channel threw an error: {0}", error.Message); OnVerbose("Event Manager is restarting due to error"); //at the moment, if an error is detected lets try and reactivate the queue //because its probably died for some reason. _isActive = false; Activate(); }); }
public virtual IObservable <T> Setup(IDeliveryScheme <T> postman) { _postman = postman; if (BackingChannel != null) { //incase an error occoured, dont send completed if (BackingChannel.HasObservers) { BackingChannel.OnCompleted(); } BackingChannel.Dispose(); } BackingChannel = new Subject <T>(); return(BackingChannel.ObserveOn(DefaultScheduler).SubscribeOn(DefaultScheduler)); }
/// <summary> /// The scheme provided to this method is not respected as the this /// backing channel is just a router that forwards requests to other eventManagers /// which already have schemes defined for them. /// /// The returned channel is a conduit to the local rxn manager defined in the systemRegistry /// </summary> /// <param name="scheme"></param> /// <returns></returns> public IObservable <T> Setup(IDeliveryScheme <T> scheme = null) { IObservable <T> received = _routingPipeline; //only setup the pipeline on the first subscription if (_setupResource == null) { if (_routingScheduler != null) { received = received.ObserveOn(_routingScheduler); } _setupResource = received.Do(RouteEvent).Subscribe(_ => { }, OnError); } return(_services.RxnsLocal.CreateSubscription <T>().FinallyR(() => { _setupResource.Dispose(); _setupResource = null; })); }
public override IObservable <IRxn> Setup(IDeliveryScheme <IRxn> postman) { return(RxObservable.DfrCreate <IRxn>(o => { var localStream = base.Setup(postman).Subscribe(o); MessagingCenter.Subscribe <Bridge, string>(Bridge.Instance, Bridge.WrappedMsg, (sender, objAsJson) => { var wrapped = objAsJson.FromJson <Bridge.MsgWrapper>(); if (wrapped != null) { o.OnNext(wrapped.Msg); } }); var xamStream = new DisposableAction(() => { MessagingCenter.Unsubscribe <Bridge, string>(Bridge.Instance, Bridge.WrappedMsg); o.OnCompleted(); }); return new CompositeDisposable(localStream, xamStream); })); }