void ActiveSessions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (var channel in e.NewItems) { var session = new Session((ITransportChannel)channel); _currentSessions.Add(session); } Console.WriteLine("Client connected"); break; case NotifyCollectionChangedAction.Remove: foreach (var channel in e.OldItems) { var session = _currentSessions.FirstOrDefault(s => s.Channel.Equals(channel)); if (session != null) { _currentSessions.Remove(session); } } Console.WriteLine("Client disconnected"); break; } }
public ProtocolBase(Session session) { _session = session; _version = 1; }