Clear() public method

public Clear ( ) : void
return void
示例#1
0
        public virtual void Dispose(bool flush)
        {
            if (m_Socket == null || m_Disposing)
            {
                return;
            }

            m_Disposing = true;

            if (flush)
            {
                flush = Flush();
            }

            try
            {
                m_Socket.Shutdown(SocketShutdown.Both);
            }
            catch (SocketException ex)
            {
                TraceException(ex);
            }

            try
            {
                m_Socket.Close();
            }
            catch (SocketException ex)
            {
                TraceException(ex);
            }

            if (m_RecvBuffer != null)
            {
                m_ReceiveBufferPool.ReleaseBuffer(m_RecvBuffer);
            }

            m_Socket = null;

            m_Buffer     = null;
            m_RecvBuffer = null;

#if NewAsyncSockets
            m_ReceiveEventArgs = null;
            m_SendEventArgs    = null;
#else
            m_OnReceive = null;
            m_OnSend    = null;
#endif

            m_Running = false;

            m_Disposed.Enqueue(this);

            if (/*!flush &&*/ !m_SendQueue.IsEmpty)
            {
                lock (m_SendQueue)
                    m_SendQueue.Clear();
            }
        }
示例#2
0
        public virtual void Dispose(bool flush)
        {
            // Genova: Usuário desconectando do servidor...
            if (m_Mobile is Mobile)
            {
                ControladorODBC.ODBCDispose(m_Mobile);
            }

            if (m_Socket == null || m_Disposing)
            {
                return;
            }

            m_Disposing = true;

            if (flush)
            {
                flush = Flush();
            }

            try {
                m_Socket.Shutdown(SocketShutdown.Both);
            } catch (SocketException ex) {
                TraceException(ex);
            }

            try {
                m_Socket.Close();

                SocketPool.ReleaseSocket(m_Socket);
            } catch (SocketException ex) {
                TraceException(ex);
            }

            if (m_RecvBuffer != null)
            {
                m_ReceiveBufferPool.ReleaseBuffer(m_RecvBuffer);
            }

            m_Socket = null;

            m_Buffer     = null;
            m_RecvBuffer = null;
            m_OnReceive  = null;
            m_OnSend     = null;
            m_Running    = false;

            m_Disposed.Enqueue(this);

            if (/*!flush &&*/ !m_SendQueue.IsEmpty)
            {
                lock (m_SendQueue)
                    m_SendQueue.Clear();
            }
        }
示例#3
0
        public void FinishDispose()
        {
            if (m_DisposeFinished)
            {
                return;
            }

            m_DisposeFinished = true;

            try
            {
                m_Socket.Shutdown(SocketShutdown.Both);
            }
            catch (SocketException ex)
            {
                TraceException(ex);
            }

            try
            {
                m_Socket.Close();
            }
            catch (SocketException ex)
            {
                TraceException(ex);
            }

            if (m_RecvBuffer != null)
            {
                m_ReceiveBufferPool.ReleaseBuffer(m_RecvBuffer);
            }

            m_Socket = null;

            m_Buffer     = null;
            m_RecvBuffer = null;
            m_Running    = false;

            m_NetServer.OnDisposed(this);

            if (!m_SendQueue.IsEmpty)
            {
                lock (m_SendQueue)
                    m_SendQueue.Clear();
            }
        }
示例#4
0
        public void Dispose(bool flush)
        {
            if (m_Socket == null || m_Disposing)
            {
                return;
            }

            m_Disposing = true;

            if (flush)
            {
                flush = Flush();
            }

            try { m_Socket.Shutdown(SocketShutdown.Both); }
            catch {}

            try { m_Socket.Close(); }
            catch {}

            if (m_RecvBuffer != null)
            {
                m_ReceiveBufferPool.ReleaseBuffer(m_RecvBuffer);
            }

            m_Socket = null;

            m_Buffer     = null;
            m_RecvBuffer = null;
            m_OnReceive  = null;
            m_OnSend     = null;
            m_Running    = false;

            m_Disposed.Enqueue(this);

            if (/*!flush &&*/ !m_SendQueue.IsEmpty)
            {
                lock (m_SendQueue)
                    m_SendQueue.Clear();
            }
        }
示例#5
0
        private void FinishDisposeNoLock()
        {
            if (m_DisposeFinished)
            {
                return;
            }

            m_DisposeFinished = true;

            try { m_Socket.Shutdown(SocketShutdown.Both); }
            catch {}

            try { m_Socket.Close(); }
            catch {}

            if (m_RecvBuffer != null)
            {
                m_ReceiveBufferPool.ReleaseBuffer(m_RecvBuffer);
            }

            m_Socket = null;

            m_Buffer     = null;
            m_RecvBuffer = null;
            m_OnReceive  = null;
            m_OnSend     = null;
            m_Running    = false;

            lock (m_Disposed)
                m_Disposed.Enqueue(this);

            if (/*!flush &&*/ !m_SendQueue.IsEmpty)
            {
                lock (m_SendQueue)
                    m_SendQueue.Clear();
            }
        }
示例#6
0
        public virtual void Dispose(bool flush)
        {
            if (Socket == null || m_Disposing)
            {
                return;
            }

            m_Disposing = true;

            if (flush)
            {
                Flush();
            }

            try
            {
                Socket.Shutdown(SocketShutdown.Both);
            }
            catch (SocketException ex)
            {
                TraceException(ex);
            }

            try
            {
                Socket.Close();
            }
            catch (SocketException ex)
            {
                TraceException(ex);
            }

            if (m_RecvBuffer != null)
            {
                lock (m_ReceiveBufferPool)
                {
                    m_ReceiveBufferPool.ReleaseBuffer(m_RecvBuffer);
                }
            }

            Socket = null;

            PacketEncoder   = null;
            PacketEncryptor = null;

            m_Buffer     = null;
            m_RecvBuffer = null;

            m_OnReceive = null;
            m_OnSend    = null;

            m_Running = false;

            lock (m_Disposed)
            {
                m_Disposed.Enqueue(this);
            }

            lock (m_SendQueue)
            {
                if (!m_SendQueue.IsEmpty)
                {
                    m_SendQueue.Clear();
                }
            }
        }
示例#7
0
文件: NetState.cs 项目: wwjwxb/ServUO
        public virtual void Dispose(bool flush)
        {
            if (Socket == null || m_Disposing)
            {
                return;
            }

            m_Disposing = true;

            if (flush)
            {
                Flush();
            }

            try
            {
                Socket.Shutdown(SocketShutdown.Both);
            }
            catch (SocketException ex)
            {
                TraceException(ex);
            }

            try
            {
                Socket.Close();
            }
            catch (SocketException ex)
            {
                TraceException(ex);
            }

            Socket = null;

            if (m_RecvBuffer != null)
            {
                lock (m_ReceiveBufferPool)
                {
                    m_ReceiveBufferPool.ReleaseBuffer(m_RecvBuffer);
                }
            }

            m_Buffer     = null;
            m_RecvBuffer = null;

            m_OnReceive = null;
            m_OnSend    = null;

            m_Running = false;

            /*
             * m_Trades = null;
             * m_Gumps = null;
             * m_Menus = null;
             * m_HuePickers = null;
             */
            lock (m_Disposed)
                m_Disposed.Enqueue(this);

            lock (m_SendQueue)
                if (!m_SendQueue.IsEmpty)
                {
                    m_SendQueue.Clear();
                }
        }