static void AsyncSubscriber2(IAsyncSubscriber <string, int> subscriber) { subscriber.Subscribe("a", async(_, _) => Console.WriteLine("NG NOT HANDLED")); var d = subscriber.Subscribe("a", async(_, _) => Console.WriteLine("OK ASSIGN")); IDisposable d1; d1 = subscriber.Subscribe("a", async(_, _) => Console.WriteLine("OK ASSIGN2")); _ = subscriber.Subscribe("a", async(_, _) => Console.WriteLine("OK ASSIGN3")); DisposableBag.Create(subscriber.Subscribe("a", async(_, _) => Console.WriteLine("OK METHOD ARG1"))); var bag = DisposableBag.CreateBuilder(); subscriber.Subscribe("a", async(_, _) => Console.WriteLine("OK METHOD CHAIN")).AddTo(bag); Enumerable.Range(1, 10).Select(async(_, _) => subscriber.Subscribe("a", async(_, _) => Console.WriteLine("OK IN LAMBDA"))); new MyClass(subscriber.Subscribe("a", async(_, _) => Console.WriteLine("OK CTOR"))); using (subscriber.Subscribe("a", async(_, _) => Console.WriteLine("OK USING"))) { } using (subscriber.Subscribe("a", async(_, _) => Console.WriteLine("OK USING2"))) { } using var u = subscriber.Subscribe("a", async(_, _) => Console.WriteLine("OK USING 3")); }
public void Callback(IAsyncResult ar) { IAsyncSubscriber subscriber = (IAsyncSubscriber)ar.AsyncState; T1 returnValue = _action.EndInvoke(ar); subscriber.Callback(returnValue); }
public FirstAsyncAsyncMessageHandler(IAsyncSubscriber <TMessage> subscriber, CancellationToken cancellationToken, AsyncMessageHandlerFilter <TMessage>[] filters) { if (cancellationToken.IsCancellationRequested) { this.core.SetException(new OperationCanceledException(cancellationToken)); return; } try { this.subscription = subscriber.Subscribe(this, filters); } catch (Exception ex) { this.core.SetException(ex); return; } if (handleCalled != 0) { this.subscription?.Dispose(); return; } if (cancellationToken.CanBeCanceled) { this.cancellationToken = cancellationToken; this.cancellationTokenRegistration = cancellationToken.Register(cancelCallback, this, false); } }
public void Bus_AsyncSubscriberException_ErrorHandlerCalled() { ImportiantData data = new ImportiantData { Info = "Valuable information" }; // Second bus subscribes to message after it was dispatched and should receive it using (var bus = new MessageBus.Core.RabbitMQBus()) { using (IAsyncSubscriber subscriber = bus.CreateAsyncSubscriber(c => c.SetReceiveSelfPublish().UseErrorSubscriber(this))) { subscriber.Subscribe <ImportiantData>(Subscribe); subscriber.Open(); using (IPublisher publisher = bus.CreatePublisher()) { publisher.Send(data); } bool wait = _ev.WaitOne(TimeSpan.FromSeconds(5)); wait.Should().BeTrue(); } } }
public ResultPresenter( IAsyncSubscriber <GameStateEnum, bool> answerResultSubscriber, ResultView[] resultViews) { _answerResultSubscriber = answerResultSubscriber; _correctResultView = resultViews[0]; _wrongResultView = resultViews[1]; }
public MainMenuPresenter( IAsyncSubscriber <GameStateEnum> gameStateSubscriber, GameObject baseObject, Button startButton) { _gameStateSubscriber = gameStateSubscriber; _baseObject = baseObject; _startButton = startButton; }
public LevelPresenter( IAsyncSubscriber <GameStateEnum, IList <int> > answersSubscriber, Func <CardView> cardFactory, IList <CardView> cards) { _answersSubscriber = answersSubscriber; _cardFactory = cardFactory; _cards = cards; }
public static ValueTask <TMessage> FirstAsync <TMessage>(this IAsyncSubscriber <TMessage> subscriber, CancellationToken cancellationToken, Func <TMessage, bool> predicate, params AsyncMessageHandlerFilter <TMessage>[] filters) { var predicateFilter = new AsyncPredicateFilter <TMessage>(predicate); filters = (filters.Length == 0) ? new[] { predicateFilter } : ArrayUtil.ImmutableAdd(filters, predicateFilter); return(new ValueTask <TMessage>(new FirstAsyncAsyncMessageHandler <TMessage>(subscriber, cancellationToken, filters), 0)); }
public static IDisposable Subscribe <TMessage>(this IAsyncSubscriber <TMessage> subscriber, Func <TMessage, CancellationToken, ValueTask> handler, Func <TMessage, bool> predicate, params AsyncMessageHandlerFilter <TMessage>[] filters) { var predicateFilter = new AsyncPredicateFilter <TMessage>(predicate); filters = (filters.Length == 0) ? new[] { predicateFilter } : ArrayUtil.ImmutableAdd(filters, predicateFilter); return(subscriber.Subscribe(new AnonymousAsyncMessageHandler <TMessage>(handler), filters)); }
public ResultAudioPresenter( IAsyncSubscriber <GameStateEnum, bool> answerResultSubscriber, AudioClipCollection[] audioClipCollections, AudioSource audioSource) { _answerResultSubscriber = answerResultSubscriber; _resultCorrectClipsIbun = audioClipCollections[0]; _resultCorrectClipsRanca = audioClipCollections[1]; _resultWrongClipsIbun = audioClipCollections[2]; _audioSource = audioSource; }
public LevelAudioPresenter( IAsyncSubscriber <GameStateEnum, int> correctAnswerSubscriber, AudioClipCollection[] audioClipCollections, AudioSource audioSource) { _correctAnswerSubscriber = correctAnswerSubscriber; _introClipsIbun = audioClipCollections[0]; _introClipsRanca = audioClipCollections[1]; _numberClipsIbun = audioClipCollections[2]; _numberClipsRanca = audioClipCollections[3]; _audioSource = audioSource; }
public Program( IPublisher <string, MyMessage> publisher, ISubscriber <string, MyMessage> subscriber, IPublisher <MyMessage> keyless1, ISubscriber <MyMessage> keyless2, IAsyncPublisher <MyMessage> asyncKeylessP, IAsyncSubscriber <MyMessage> asyncKeylessS, IRequestHandler <Ping, Pong> pingponghandler, //PingHandler pingpingHandler, IRequestAllHandler <Ping, Pong> pingallhandler, IPublisher <int> intP, ISubscriber <int> intS, IServiceScopeFactory scopeF, MessagePipeDiagnosticsInfo diagnosticsInfo, IServiceProvider provider ) { this.provider = provider; this.scopeF = scopeF; this.publisher = publisher; this.subscriber = subscriber; this.keylessP = keyless1; this.keylessS = keyless2; this.asyncKeylessP = asyncKeylessP; this.asyncKeylessS = asyncKeylessS; this.pingponghandler = pingponghandler; //this.pingpingHandler = pingpingHandler; this.pingallhandler = pingallhandler; this.intPublisher = intP; this.intSubscriber = intS; this.diagnosticsInfo = diagnosticsInfo; var r1 = provider.GetRequiredService <IRequestHandler <string, int> >(); r1.Invoke("foo"); }
public InMemoryDistributedSubscriber(IAsyncSubscriber <TKey, TMessage> subscriber) { this.subscriber = subscriber; }
public static ValueTask <TMessage> FirstAsync <TKey, TMessage>(this IAsyncSubscriber <TKey, TMessage> subscriber, TKey key, CancellationToken cancellationToken, params AsyncMessageHandlerFilter <TMessage>[] filters) where TKey : notnull { return(new ValueTask <TMessage>(new FirstAsyncAsyncMessageHandler <TKey, TMessage>(subscriber, key, cancellationToken, filters), 0)); }
public static ValueTask <TMessage> FirstAsync <TMessage>(this IAsyncSubscriber <TMessage> subscriber, CancellationToken cancellationToken, params AsyncMessageHandlerFilter <TMessage>[] filters) { return(new ValueTask <TMessage>(new FirstAsyncAsyncMessageHandler <TMessage>(subscriber, cancellationToken, filters), 0)); }
public AsyncEnumerableAsyncSubscriber(IAsyncSubscriber <TMessage> subscriber, AsyncMessageHandlerFilter <TMessage>[] filters) { this.subscriber = subscriber; this.filters = filters; }
public static IAsyncEnumerable <TMessage> AsAsyncEnumerable <TKey, TMessage>(this IAsyncSubscriber <TKey, TMessage> subscriber, TKey key, params AsyncMessageHandlerFilter <TMessage>[] filters) where TKey : notnull { return(new AsyncEnumerableAsyncSubscriber <TKey, TMessage>(key, subscriber, filters)); }
public static IAsyncEnumerable <TMessage> AsAsyncEnumerable <TMessage>(this IAsyncSubscriber <TMessage> subscriber, params AsyncMessageHandlerFilter <TMessage>[] filters) { return(new AsyncEnumerableAsyncSubscriber <TMessage>(subscriber, filters)); }
// pubsub-keyless-async public static IDisposable Subscribe <TMessage>(this IAsyncSubscriber <TMessage> subscriber, Func <TMessage, CancellationToken, ValueTask> handler, params AsyncMessageHandlerFilter <TMessage>[] filters) { return(subscriber.Subscribe(new AnonymousAsyncMessageHandler <TMessage>(handler), filters)); }
public unsafe PublishOps() { var provider = new ServiceCollection().AddMessagePipe().BuildServiceProvider(); prism = new Prism.Events.EventAggregator().GetEvent <Message>(); prismStrong = new Prism.Events.EventAggregator().GetEvent <Message>(); var mdiatr = new ServiceCollection().AddMediatR(typeof(PublishOps).Assembly).BuildServiceProvider(); medi = mdiatr.GetRequiredService <IMediator>(); p = provider.GetRequiredService <IPublisher <Message> >(); var s = provider.GetRequiredService <ISubscriber <Message> >(); keyed = provider.GetRequiredService <IPublisher <Guid, Message> >(); var keyedS = provider.GetRequiredService <ISubscriber <Guid, Message> >(); hub = Hub.Default; var px = new ServiceCollection().AddMessagePipe().BuildServiceProvider(); filter1 = px.GetRequiredService <IPublisher <Message> >(); var filter1Sub = px.GetRequiredService <ISubscriber <Message> >(); var px2 = new ServiceCollection().AddMessagePipe().BuildServiceProvider(); filter2 = px2.GetRequiredService <IPublisher <Message> >(); var filter2Sub = px2.GetRequiredService <ISubscriber <Message> >(); m = new Message(); subject = new Subject <Message>(); signalBus = SetupZenject(); easyMsgHub = new MessageHub(); asyncP = provider.GetRequiredService <IAsyncPublisher <Message> >(); asyncS = provider.GetRequiredService <IAsyncSubscriber <Message> >(); #if WinBenchmark mvvmLight = new Messenger(); mvvmLightStrong = new Messenger(); #endif toolkitStrong = new Microsoft.Toolkit.Mvvm.Messaging.StrongReferenceMessenger(); toolkitWeak = new Microsoft.Toolkit.Mvvm.Messaging.WeakReferenceMessenger(); simpleArray = new PlainAction[8]; actionDelegate = new Action[8]; interfaceArray = new IInvoke[8]; for (int i = 0; i < 8; i++) { s.Subscribe(new EmptyMessageHandler()); prism.Subscribe(lambdaRef.Delegate); prismStrong.Subscribe(_ => { }, true); ev += _ => { }; subject.Subscribe(_ => { }); hub.Subscribe <Message>(_ => { }); #if WinBenchmark UniRx.MessageBroker.Default.Receive <Message>().Subscribe(new NopObserver()); mvvmLight.Register <Message>(this, _ => { }, false); // mvvmLightStrong.Register<Message>(this, _ => { }, true); #endif keyedS.Subscribe(key, _ => { }); filter1Sub.Subscribe(new EmptyMessageHandler(), new EmptyMessageHandlerFilter()); filter2Sub.Subscribe(new EmptyMessageHandler(), new EmptyMessageHandlerFilter(), new EmptyMessageHandlerFilter()); easyMsgHub.Subscribe <Message>(_ => { }); simpleArray[i] = new PlainAction(); actionDelegate[i] = new PlainAction().DelegateAction; interfaceArray[i] = new PlainAction(); asyncS.Subscribe((_, _) => default(ValueTask)); toolkitStrong.Register <Message>(new object(), lambdaRef2.Delegate); toolkitWeak.Register <Message>(new object(), lambdaRef2.Delegate); } signalBus.Subscribe <Message>(_ => { }); signalBus.Subscribe <Message>(_ => { }); signalBus.Subscribe <Message>(_ => { }); signalBus.Subscribe <Message>(_ => { }); signalBus.Subscribe <Message>(_ => { }); signalBus.Subscribe <Message>(_ => { }); signalBus.Subscribe <Message>(_ => { }); signalBus.Subscribe <Message>(_ => { }); }
static IDisposable Ret(IAsyncSubscriber <int, int> subscriber) { return(subscriber.Subscribe(0, async(_, _) => Console.WriteLine("OK RETURN"))); }