コード例 #1
0
 /// <summary>
 /// Remove a session from the session pool, no matter whether it exists or not
 /// </summary>
 /// <param name="session"></param>
 public void RemoveSession(FtpListenerSession session)
 {
     for (int i = 0; i < m_PoolCapacity; i++)
     {
         if (m_Sessions[i] == session)
         {
             m_Sessions[i] = null;
             m_Count--;
             break;
         }
     }
     return;
 }
コード例 #2
0
        /// <summary>
        /// Find the session id of that session
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        public int SearchSession(FtpListenerSession session)
        {
            int sessionId = -1;

            for (int i = 0; i < m_PoolCapacity; i++)
            {
                if (m_Sessions[i] == session)
                {
                    sessionId = i;
                    break;
                }
            }
            return sessionId;
        }
コード例 #3
0
        /// <summary>
        /// Find the session id of that session
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        public int SearchSession(FtpListenerSession session)
        {
            int sessionId = -1;

            for (int i = 0; i < m_PoolCapacity; i++)
            {
                if (m_Sessions[i] == session)
                {
                    sessionId = i;
                    break;
                }
            }
            return(sessionId);
        }
コード例 #4
0
 /// <summary>
 /// Add a new session into the session pool and add an unique id to it
 /// </summary>
 /// <param name="session">the session to be added</param>
 /// <returns>the id of that session, if no free id then return -1</returns>
 public int AddSession(FtpListenerSession session)
 {
     int newSessionId = 0;
     if (m_Sessions == null)
     {
         throw new NullReferenceException("Session pool initialization failed.");
     }
     for (int i = 0; i <= m_PoolCapacity; i++)
     {
         // start searching free id from previous result
         newSessionId = (i + m_LastSessionId) % m_PoolCapacity;
         if (m_Sessions[newSessionId] == null)    // TODO: check the status of the session
         {
             session.SessionId = newSessionId;
             m_Sessions[newSessionId] = session;
             m_LastSessionId = newSessionId;
             m_Count++;
             return newSessionId;
         }
     }
     return -1;
 }
コード例 #5
0
        /// <summary>
        /// Add a new session into the session pool and add an unique id to it
        /// </summary>
        /// <param name="session">the session to be added</param>
        /// <returns>the id of that session, if no free id then return -1</returns>
        public int AddSession(FtpListenerSession session)
        {
            int newSessionId = 0;

            if (m_Sessions == null)
            {
                throw new NullReferenceException("Session pool initialization failed.");
            }
            for (int i = 0; i <= m_PoolCapacity; i++)
            {
                // start searching free id from previous result
                newSessionId = (i + m_LastSessionId) % m_PoolCapacity;
                if (m_Sessions[newSessionId] == null)    // TODO: check the status of the session
                {
                    session.SessionId        = newSessionId;
                    m_Sessions[newSessionId] = session;
                    m_LastSessionId          = newSessionId;
                    m_Count++;
                    return(newSessionId);
                }
            }
            return(-1);
        }
コード例 #6
0
 /// <summary>
 /// Remove a session from the session pool, no matter whether it exists or not
 /// </summary>
 /// <param name="session"></param>
 public void RemoveSession(FtpListenerSession session)
 {
     for (int i = 0; i < m_PoolCapacity; i++)
     {
         if (m_Sessions[i] == session)
         {
             m_Sessions[i] = null;
             m_Count--;
             break;
         }
     }
     return;
 }
コード例 #7
0
        private FtpListenerSession m_Session = null;                    // reference back to the session it belongs to

        // Methods
        internal FtpListenerContext(FtpListenerSession session, FtpListenerRequest request)
        {
            m_ResponseToClient = new FtpListenerResponse(request, session);
            m_ClientRequest = request;
            m_Session = session;
        }