Esempio n. 1
0
        /// <summary>
        /// 发送数据。发送时,默认在头部加上4字节的key
        /// </summary>
        /// <param name="buf"></param>
        public void Send(byte[] buf)
        {
            byte[] newbuf = new byte[buf.Length + 4];
            //把key附上,服务端合法性检测用
            KCPLib.ikcp_encode32u(newbuf, 0, (uint)m_Key);
            Array.Copy(buf, 0, newbuf, 4, buf.Length);

            m_Kcp.Send(newbuf);
            m_NeedUpdateFlag = true;
            var e = Event;

            if (e != null)
            {
                e(UdpClientEvents.Send, buf);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 和Update同一个线程调用
 /// </summary>
 /// <param name="buf"></param>
 public void Send(byte[] buf)
 {
     m_Kcp.Send(buf, 0, buf.Length);
     m_NeedUpdateFlag = true;
 }