private void ProcessAccept(SocketAsyncEventArgs eventArgs) { // Create a client session if (eventArgs.SocketError == SocketError.Success) { // Create a new session and connect to accepted socket GemSession session = new GemSession(this); Sessions.TryAdd(session.Id, session); session.Connect(eventArgs.AcceptSocket); } else { Console.WriteLine($"{Peer} : Accept failure : {eventArgs.SocketError}"); } // Accept again unless stopping if (!Stopping) { StartAccept(eventArgs); } }
internal void Disconnect(GemSession session) { // TODO : Verify that dispose gets called when the client reference is removed from the list Sessions.TryRemove(session.Id, out GemSession _); }