예제 #1
0
        public virtual bool HandleReceive(NetState ns)
        {
            ByteQueue buffer = ns.Buffer;

            if (buffer == null || buffer.Length <= 0)
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        public virtual void Dispose(bool flush)
        {
            if (mSocket == null || mDisposing)
            {
                return;
            }

            mDisposing = true;

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

            if (flush)
            {
                Flush();
            }

            try {
                mSocket.Shutdown(SocketShutdown.Both);
            } catch (SocketException ex) {
                Debug.WriteLine(ex);
            }

            try {
                mSocket.Close();
                SocketPool.ReleaseSocket(mSocket);
            } catch (SocketException ex) {
                Debug.WriteLine(ex);
            }

            mSocket = null;

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

            mDisposed.Enqueue(this);

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