Example #1
0
    // 读取数据
    private void ReadData()
    {
        byte[] data = NetEncode.Decode(ref receiveCache);
        //说明获取到一条完整数据
        if (data != null)
        {
            PacketBase msg = NetSerilizer.DeSerialize <PacketBase>(data);
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            string dataStr = Utils.ToStr(Utils.DeSerialize(msg));
            Debug.LogFormat("<<=:{0}; code:{1}; msg:{2};data:[{3}]", msg.packetType, msg.code, msg.msg, dataStr);
            //Debug.LogFormat("<<=:{0}; code:{1}; msg:{2};data:[{3}]", msg.packetType, msg.code, msg.msg, dataStr);
#endif

            //if(msg.code != 0 && string.IsNullOrEmpty(msg.msg) == false)
            //{
            //    Game.DialogMgr.ShowDialog1Btn(msg.msg);
            //}

            if (receiveCallBack != null)
            {
                receiveCallBack(msg);
            }
            //尾递归,继续读取数据
            ReadData();
        }
        else
        {
            isReceiving = false;
        }
    }
Example #2
0
 /// <summary>
 /// 读取数据
 /// </summary>
 private void ReadData()
 {
     byte[] data = NetEncode.Decode(ref receiveCache);
     //说明数据保存成功
     if (data != null)
     {
         NetModel item = DeSerilizer(data);
         UnityEngine.Debug.Log(item.Message);
         if (receiveCallBack != null)
         {
             receiveCallBack(item);
         }
         //尾递归,继续读取数据
         ReadData();
     }
     else
     {
         isReceiving = false;
     }
 }
Example #3
0
    /// <summary>
    /// 读取数据
    /// </summary>
    private void ReadData()
    {
        byte[] data = NetEncode.Decode(ref receiveCache);

        //如果数据读取成功
        if (null != data)
        {
            NetModel item = NetSerilizer.DeSerialize(data);
            Debug.Log(item.ID + "," + item.Commit + "," + item.Message);
            if (null != receiveCallback)
            {
                receiveCallback(item);
            }
            //尾递归,继续处理数据
            ReadData();
        }
        else
        {
            isReceiving = false;
        }
    }