public bool Add(FABChannel channel) { ConcurrentDictionary <FABChannelId, FABChannel> map = channel is IServerChannel ? this.serverChannels : this.nonServerChannels; bool added = map.TryAdd(channel.Id, channel); if (added) { channel.CloseCompletion.ContinueWith(x => this.Remove(channel)); } return(added); }
public bool Remove(FABChannel channel) { FABChannel ch; if (channel is IServerChannel) { return(this.serverChannels.TryRemove(channel.Id, out ch)); } else { return(this.nonServerChannels.TryRemove(channel.Id, out ch)); } }
public bool Contains(FABChannel item) { FABChannel channel; if (item is IServerChannel) { return(this.serverChannels.TryGetValue(item.Id, out channel) && channel == item); } else { return(this.nonServerChannels.TryGetValue(item.Id, out channel) && channel == item); } }