public void Initialize(Socket socket, AsyncSocketSessionBase socketSession)
        {
            var token = SocketEventArgs.UserToken as AsyncUserToken;

            token.Socket        = socket;
            token.SocketSession = socketSession;
        }
        private void session_Closed(object sender, SocketSessionClosedEventArgs e)
        {
            try
            {
                _maxConnectionSemaphore.Release();
                AsyncSocketSessionBase socketSession = sender as AsyncSocketSessionBase;
                socketSession.Closed            -= new EventHandler <SocketSessionClosedEventArgs>(session_Closed);
                socketSession.OnRequestReceived -= new EventHandler <SocketPlainTextEventArgs>(OnRequestReceived);

                if (socketSession != null && this.m_ReadWritePool != null)
                {
                    this.m_ReadWritePool.Push(socketSession.SocketAsyncProxy);
                }
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("AsyncSocketServer session_Closed Exception:", ex);
                }
            }
        }
 public StreamEventArgs(AsyncSocketSessionBase session, PacketBase packetContext)
 {
     CurrentSession = session;
     PacketContext  = packetContext;
 }