Example #1
0
        //--------------------------- KCP相关 ----------------------------------------------//

        void init_kcp(UInt32 conv)
        {
            if (m_Kcp != null)
            {
                return;
            }
            m_Kcp = new KCP(conv, (byte[] buf, int size) =>
            {
                // m_UdpClient.SendBuf(buf, size);
            });

            // fast mode.
            m_Kcp.NoDelay(1, 10, 2, 1);
            m_Kcp.WndSize(128, 128);
        }
Example #2
0
        private void CloseSocket()
        {
            if (m_Udp != null)
            {
                try
                {
                    m_Udp.Close();
                }
                catch
                { }
                m_Udp = null;
            }

            // 清空KCP
            m_Kcp = null;

            FreeSendQueue();

            // 清理掉所有处理
            ClearAllProcessPackets();
        }