public long Subscribe(ISubscribeRequest <TMessage> request, SubscribeOptions options, string topicUri) { lock (mLock) { WampRawTopic <TMessage> rawTopic; IWampCustomizedSubscriptionId customizedSubscriptionId = mTopicContainer.GetSubscriptionId(topicUri, options); if (!mTopicUriToTopic.TryGetValue(customizedSubscriptionId, out rawTopic)) { rawTopic = CreateRawTopic(topicUri, options, customizedSubscriptionId); IWampRegistrationSubscriptionToken subscriptionToken = mTopicContainer.Subscribe(rawTopic, topicUri, options); long subscriptionId = subscriptionToken.TokenId; mSubscriptionIdToTopic.TryAdd(subscriptionId, rawTopic); rawTopic.SubscriptionId = subscriptionId; rawTopic.SubscriptionDisposable = subscriptionToken; } rawTopic.Subscribe(request, options); return(rawTopic.SubscriptionId); } }
public WampRawTopic(string topicUri, SubscribeOptions subscribeOptions, IWampCustomizedSubscriptionId customizedSubscriptionId, IWampEventSerializer serializer, IWampBinding <TMessage> binding) { mSerializer = serializer; mSubscriberBook = new RawTopicSubscriberBook(this); mTopicUri = topicUri; mBinding = binding; mSubscribeOptions = subscribeOptions; mCustomizedSubscriptionId = customizedSubscriptionId; }
private WampRawTopic <TMessage> CreateRawTopic(string topicUri, SubscribeOptions subscriptionOptions, IWampCustomizedSubscriptionId customizedSubscriptionId) { WampRawTopic <TMessage> newTopic = new WampRawTopic <TMessage>(topicUri, subscriptionOptions, customizedSubscriptionId, mEventSerializer, mBinding); mTopicUriToTopic.TryAdd(customizedSubscriptionId, newTopic); newTopic.TopicEmpty += OnTopicEmpty; return(newTopic); }