/// <summary> /// Method for registering publisher /// </summary> /// <param name="eventObservable"></param> /// <typeparam name="TObservable"></typeparam> /// <typeparam name="TResult"></typeparam> /// <returns></returns> public static bool RegisterPublisher <TObservable, TResult> (IWampEventHandler <TObservable, TResult> eventObservable) { var wampRouter = ServiceLocator.GetRequiredService <WampRouter>(); if (wampRouter == null) { return(false); } wampRouter.RegisterPublisher(eventObservable); return(true); }
public void RegisterPublisher <TObservable, TResult> (string realmName, IWampEventHandler <TObservable, TResult> eventObservable) { IWampHostedRealm realm = _host.RealmContainer.GetRealmByName(realmName); ISubject <TResult> subject = realm.Services.GetSubject <TResult>(eventObservable.Topic); IObservable <TObservable> observableEvent = eventObservable.Event; observableEvent.Subscribe(x => { if (realm.TopicContainer.TopicUris.FirstOrDefault(f => f.Equals(eventObservable.Topic)) == null) { Log.LogWarning(nameof(WampRouter), $"Trying to publish on topic: {eventObservable.Topic}, but there is no subscriber to this topic"); } else { subject.OnNext(eventObservable.GetNewData()); } }); }
public void RegisterPublisher <TObservable, TResult> (IWampEventHandler <TObservable, TResult> eventObservable) { RegisterPublisher(DefaultRealmName, eventObservable); }