Example #1
0
        // если канал здох, надо отстрелять подписчика - в следующий раз придет с новым каналом
        void commChannel_StateChanged(ICommunicationChannel channel, ConnectionState state)
        {
            if (!channel.IsConnected())
            {
                lock (_subscribers)
                {
                    IEnumerable <Guid> toKill =
                        (from s in _subscribers.Where(t =>
                                                      (t.Value.SendChannel is ICommunicationChannel) &&
                                                      channel.ID == ((ICommunicationChannel)t.Value.SendChannel).ID)
                         select s.Key).ToList();

                    foreach (Guid id in toKill)
                    {
                        _subscribers.Remove(id);
                    }
                }
            }
        }