コード例 #1
0
 private void AddSubscription(Subscription sub)
 {
     lock (_syncRoot)
     {
         if (_subscriptions.ContainsKey(sub.Topic.Key) == true)
             throw new Exception("Multiple subscriptions for the same topic are not supported.");
         _subscriptions[sub.Topic.Key] = sub;
     }
 }
コード例 #2
0
        internal static void Add(ITopic topic, Action<RealTimeMessage> handler)
        {
            if (handler == null) throw new ArgumentException("Event handler cannot be null.");
            var subscriptionManager = ObjectFactory.Build<ISubscriptionManager>();
            lock (_lock)
            {
                // Get existing
                var sub = subscriptionManager.Get(topic);
                // Create if not exists.
                if (sub == null)
                {
                    sub = new Subscription { Topic = topic };
                    sub.Triggered += handler;
                    subscriptionManager.Subscribe(sub);
                }
                else
                {
                    sub.Triggered += handler;
                }
                
            }

        }
コード例 #3
0
 public void Subscribe(Subscription subscription)
 {
     AddSubscription(subscription);
 }