Beispiel #1
0
        //关闭
        public void Close()
        {
            // UnityEngine.Debug.LogWarningFormat("Close UDP socket:");
            Disconnect();

            //释放线程
            if (null != m_ThreadSend)
            {
                m_ThreadSend.Abort();
                m_ThreadSend = null;
            }

            //释放发包内存池
            if (null != m_oSendDataSwap)
            {
                m_oSendDataSwap.Release();
                m_oSendDataSwap = null;
            }

            //释放udp客户端
            if (null != mUdpClient)
            {
                mUdpClient.Close();
                mUdpClient = null;
            }

            //释放发送队列
            if (null != m_QueueToSend)
            {
                m_QueueToSend.Clear();
                m_QueueToSend = null;
            }

            //释放接收队列
            if (null != mRecvQueue)
            {
                mRecvQueue.Clear();
                mRecvQueue = null;
            }

            //重置状态
            reset_state();

            //清空缓存
            packbuffer      = null;
            recievebuffer   = null;
            mHandshakePack  = null;
            mHeartPack      = null;
            mDisconnectPack = null;

            //清空回调
            m_socketSink = null;
        }
Beispiel #2
0
 public UDPSocketClient()
 {
     m_oSendDataSwap = new ThreadDataSwap();
     m_oSendDataSwap.Create();
 }