void session_DisconnectHandler(object sender, EventArgs e) { Console.WriteLine("Session Disconnecting: {0}", sender); SOCKSServerSession session = sender as SOCKSServerSession; lock (SessionLock) { if (Sessions.Contains(session) == true) { Sessions.Remove(session); } } }
void Listener_OnNewConnection(System.Net.Sockets.Socket s) { Console.WriteLine("Session Connecting: {0}", s); SOCKSServerSession session = new SOCKSServerSession(s, this); lock (SessionLock) { Sessions.Add(session); } session.DisconnectHandler += new SocketClient.SocketEventHandler(session_DisconnectHandler); session.Start(); }