WampSharp helpfully provides a means to subscribe to an IObservable, which notionally is available from both clients, and from the host/router process.
However, I have found that in the current version, whilst IWampRealmServiceProvider.GetSubject()
provides a subject on the host as well as clients, calling the OnNext()
method of that subject will never result in subscriptions being executed unless those subscriptions are on clients. On the host, the message just... vanishes into the ether (or seems to).
Anyone have any idea what I'm doing wrong?
Approximate trimmed down example below:
void ServiceStartup() {
...
_WampHost = new DefaultWampHost(uri.ToString());
_Realm = _Host.RealmContainer.GetRealmByName(realm);
_WampSubject = _Realm.Services.GetSubject<string>("com.status.topic1");
_WampSubject.Subscribe(OutputMessageToLog, OnSubjectError, OnSubjectDone);
...
_WampHost.Open();
}
// Called from elsewhere in the application, typically from a threadpool thread
void SendViaWamp(string message){
_WampSubject.OnNext(message);
}
...
void OutputMessageToLog(string message)
{
// Never hit
_Log.Info(message);
}