Exemplo n.º 1
0
 public override bool Subscribe(string channel, SubscribableListener del)
 {
     bool retval = base.Subscribe(channel, del);
     if (retval)
         subscribed_delegates.Add(new Tuple<string, SubscribableListener>(channel, del));
     return retval;
 }
Exemplo n.º 2
0
        public static ILogger GetLogger()
        {
            lock (_lockObj)
            {
                if (_logger != null)
                {
                    return(_logger);
                }

                var listener = new SubscribableListener();
                listener.MessageLogged += Listener_MessageLogged;
                _logger = listener;

                return(_logger);
            }
        }
Exemplo n.º 3
0
 public override void PatternUnsubscribe(string channel_pattern, SubscribableListener del)
 {
     base.PatternUnsubscribe(channel_pattern, del);
     int index = -1;
     for (int i = 0; i < subscribed_delegates.Count; i++)
     {
         if (subscribed_delegates[i].Item1 == channel_pattern && subscribed_delegates[i].Item2 == del)
         {
             index = i;
             break;
         }
     }
     if (index > -1)
     {
         subscribed_delegates.RemoveAt(index);
     }
 }
Exemplo n.º 4
0
 public override bool Unsubscribe(string channel, SubscribableListener del)
 {
     bool retval = base.Unsubscribe(channel, del);
     if (retval)
     {
         int index = -1;
         for (int i = 0; i < subscribed_delegates.Count; i++)
         {
             if (subscribed_delegates[i].Item1 == channel && subscribed_delegates[i].Item2 == del)
             {
                 index = i;
                 break;
             }
         }
         if (index > -1)
         {
             subscribed_delegates.RemoveAt(index);
         }
     }
     return retval;
 }
Exemplo n.º 5
0
 public override void PatternSubscribe(string channel_pattern, SubscribableListener del)
 {
     base.PatternSubscribe(channel_pattern, del);
     pattern_subscribed_delegates.Add(new Tuple<string, SubscribableListener>(channel_pattern, del));
 }
Exemplo n.º 6
0
 public virtual void PatternUnsubscribe(string channel_pattern, SubscribableListener del)
 {
     if (_subscribable != null)
         _subscribable.PatternSubscribe(channel_pattern, del);
 }
Exemplo n.º 7
0
 public virtual bool Unsubscribe(string channel, SubscribableListener del)
 {
     if (_subscribable != null)
         return _subscribable.Unsubscribe(channel, del);
     return false;
 }
Exemplo n.º 8
0
 public bool Unsubscribe(string channel, SubscribableListener del)
 {
     return SubscribableManager.Unsubscribe(channel, del);
 }
Exemplo n.º 9
0
 public void PatternUnsubscribe(string channel_pattern, SubscribableListener del)
 {
     SubscribableManager.PatternUnsubscribe(channel_pattern, del);
 }
Exemplo n.º 10
0
 public void PatternSubscribe(string channel_pattern, SubscribableListener del)
 {
     List<SubscribableListener> pattern_channel = pattern_channels.GetValueOrDefault(channel_pattern, DefaultPatternValue);
     if (!pattern_channel.Contains(del))
     {
         pattern_channel.Add(del);
     }
     foreach(KeyValuePair<string, List<SubscribableListener>> channel in channels.GetAllMatchingRegex(channel_pattern))
     {
         if (!channel.Value.Contains(del))
         {
             channel.Value.Add(del);
         }
     }
 }
Exemplo n.º 11
0
 public bool Unsubscribe(string channel, SubscribableListener del)
 {
     List<SubscribableListener> subscribers = channels.GetValueOrDefault(channel, DefaultChannelValue);
     if (!subscribers.Contains(del))
     {
         return false;
     }
     subscribers.Remove(del);
     return true;
 }
Exemplo n.º 12
0
 public void PatternUnsubscribe(string channel_pattern, SubscribableListener del)
 {
     List<SubscribableListener> pattern_channel = pattern_channels.GetValueOrDefault(channel_pattern, DefaultPatternValue);
     if (pattern_channel.Contains(del))
     {
         pattern_channel.Remove(del);
     }
     IEnumerable<KeyValuePair<string, List<SubscribableListener>>> matching_channels =
         channels.GetAllMatchingRegex(channel_pattern);
     List<string> channels_to_remove = new List<string>();
     foreach (KeyValuePair<string, List<SubscribableListener>> channel in matching_channels)
     {
         if (channel.Value.Contains(del))
         {
             channel.Value.Remove(del);
         }
         if (channel.Value.Count == 0)
         {
             channels_to_remove.Add(channel.Key);
         }
     }
 }