Ejemplo n.º 1
0
        public virtual void Dispose(bool flush)
        {
            if (mDisposing)
            {
                return;
            }

            ServerConsole.StatusLine("{0}: Disconnected.", this);
            mDisposing = true;

            //##PACKET## Logout
            Thread.Sleep(100);

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

            // Check for existing objects in the World
            // FIXME - Account cant be removed
            // We need to check using World.GetAccount() after a new connection
            // from login -> char or char -> world
            // ...
            //if (Account != null) {
            //	World.RemoveObject(Account);
            //}

            if (mSocket != null)
            {
                try {
                    mSocket.Shutdown(SocketShutdown.Both);
                } catch (SocketException ex) {
                    ExceptionHandler.Trace(ex);
                }

                try {
                    mSocket.Close();
                    SocketPool.ReleaseSocket(mSocket);
                } catch (SocketException ex) {
                    ExceptionHandler.Trace(ex);
                }
                mSocket = null;
            }

            mBuffer     = null;
            mRecvBuffer = null;
            mOnReceive  = null;
            mOnSend     = null;
            mRunning    = false;

            mDisposed.Enqueue(this);

            if (!mSendQueue.IsEmpty)
            {
                lock (mSendQueue) {
                    mSendQueue.Clear();
                }
            }
        }
Ejemplo n.º 2
0
        private void Release(Socket socket)
        {
            try {
                socket.Shutdown(SocketShutdown.Both);
            } catch (SocketException ex) {
                ExceptionHandler.Trace(ex);
            }

            try {
                socket.Close();

                SocketPool.ReleaseSocket(socket);
            } catch (SocketException ex) {
                ExceptionHandler.Trace(ex);
            }
        }