public IDisposable Stream(int id, Action <Message> action, IObserver <ConnectionState> observer) { var streamer = new Streamer(id, action, observer); _streamers.Add(streamer); return(ActionDisposable.Create(() => _streamers.Remove(streamer))); }
public IDisposable Subscribe <T>(Action <T> handler) { if (handler == null) { throw new ArgumentNullException("handler"); } lock (m_Subscriptions) { if (!m_Subscriptions.Contains(handler)) { m_Subscriptions.Add(handler); } } return(ActionDisposable.Create(() => { lock (m_Subscriptions) { m_Subscriptions.Remove(handler); } })); }