Exemplo n.º 1
0
        public virtual void Stop()
        {
            m_State = -1;
            m_ListenWatcher.Set();

            lock (m_ListenWatcher)
            {
                if (m_ListenSocket != null)
                {
                    try
                    {
                        m_ListenSocket.Close();
                        m_ListenSocket.Dispose();
                    }
                    catch { }

                    m_ListenSocket = null;
                }
            }

            m_ListeningPort = 0;
            m_ListeningIp   = "";

            Dictionary <Int32, Session> sessions = GetSessions();

            if (sessions != null && sessions.Count > 0)
            {
                foreach (KeyValuePair <Int32, Session> item in sessions)
                {
                    try
                    {
                        Session session = item.Value;
                        session.Close();
                    }
                    catch { }
                }
            }

            if (sessions != null)
            {
                sessions.Clear();
            }
            lock (m_SessionGroup)
            {
                m_SessionGroup.StopCheckingIdle();
                m_SessionGroup.Clear();
                m_NextSessionID = 0;
            }
        }