示例#1
0
 void InitializePollManagers()
 {
     if (this.MinimizeConnectionUse)
     {
         this.pollManager = new HttpLongPollManager(this.BaseAddress.AbsoluteUri, this.MaxBufferSize);
     }
     else
     {
         this.pollManagers = new Dictionary <int, List <HttpLongPollManager> >();
     }
 }
示例#2
0
        public void SubscribeAsync(Subscription subscription)
        {
            if (subscription == null)
            {
                throw new ArgumentNullException("subscription");
            }
            if (subscription.TopicId <= 0)
            {
                throw new InvalidOperationException("TopicId must be a positive integer.");
            }
            if (subscription.From < 0)
            {
                throw new InvalidOperationException("From must be a non-negative integer.");
            }

            HttpLongPollManager pollManager = null;

            if (this.MinimizeConnectionUse)
            {
                pollManager = this.pollManager;
            }
            else
            {
                lock (this.syncRoot)
                {
                    if (!this.pollManagers.ContainsKey(subscription.TopicId))
                    {
                        this.pollManagers[subscription.TopicId] = new List <HttpLongPollManager>();
                    }
                    pollManager = new HttpLongPollManager(this.BaseAddress.AbsoluteUri, this.MaxBufferSize);
                    this.pollManagers[subscription.TopicId].Add(pollManager);
                }
            }

            subscription.SynchronizationContext = SynchronizationContext.Current;
            pollManager.AddSubscription(subscription);
        }