public bool Unsubscribe(IWampClientProxy <TMessage> client) { bool result; ImmutableHashSetInterlocked.Remove(ref mRemoteObservers, new RemoteObserver(client)); result = ImmutableInterlocked.TryRemove(ref mSessionIdToSubscription, client.Session, out Subscription subscription); RemoveAuthenticationData(client); return(result); }
public RemoteObserver Subscribe(IWampClientProxy <TMessage> client) { Subscription subscription; if (!mSessionIdToSubscription.TryGetValue(client.Session, out subscription)) { RemoteObserver result = new RemoteObserver(client); ImmutableHashSetInterlocked.Add(ref mRemoteObservers, result); subscription = new Subscription(mRawTopic, client, result); ImmutableInterlocked.TryAdd(ref mSessionIdToSubscription, client.Session, subscription); subscription.Open(); } return(subscription.Observer); }