Example #1
0
        private void RecvLarger(byte[] recvByte, int realLength)
        {
            int tmpLength = allDataLengh - curRecLength;

            IFileTools.MemCpy(allRecData, recvByte, curRecLength, tmpLength);
            curRecLength += tmpLength;
            RecvOneMsgOver();

            int remainLenth = realLength - tmpLength;

            byte[] remainByte = new byte[remainLenth];

            //   Debug.Log("recvByte larger =="+ recvByte.Length);

            //Debug.Log("recvByte larger tmpLength ==" + tmpLength);


            //Debug.Log("recvByte larger tmpLength 2222==" + remainLenth);


            //Debug.Log("remainByte  444444==" + remainByte.Length);

            IFileTools.MemCpy(remainByte, 0, recvByte, tmpLength, remainLenth);

            RecevByte(remainByte, remainLenth);
        }
Example #2
0
        private void  RecvOneAll(byte[] recvByte, int realLength)
        {
            IFileTools.MemCpy(allRecData, recvByte, curRecLength, realLength);
            curRecLength += realLength;

            RecvOneMsgOver();
        }
Example #3
0
        private void RecvHead(byte[] recByte, int reallength)
        {
            // if (curRecLength < headByte.Length) //小于头长度
            //    {
            int tmpReal = headByte.Length - curRecLength;


            int tmpLength = curRecLength + reallength;

            if (tmpLength < headByte.Length)     //比头小
            {
                //  Debug.Log("small  head");
                IFileTools.MemCpy(headByte, recByte, curRecLength, reallength);
                curRecLength += tmpReal;
            }
            else
            {
                //  Debug.Log("big head");

                IFileTools.MemCpy(headByte, recByte, curRecLength, tmpReal);
                curRecLength += tmpReal;



                allDataLengh = IFileTools.ByteToInt(headByte) + headLength;
                allRecData   = new byte[allDataLengh];


                //头考入
                IFileTools.MemCpy(allRecData, 0, headByte, 0, headByte.Length);


                // 剩下的 在放入
                int tmpRemain = reallength - tmpReal;
                if (tmpRemain > 0)
                {
                    byte[] tmpBytes = new byte[tmpRemain];

                    IFileTools.MemCpy(tmpBytes, 0, recByte, tmpReal, tmpRemain);


                    RecevByte(tmpBytes, tmpRemain);
                }
                else
                {
                    RecvOneMsgOver();
                }
            }

            //     }
            //else// 大于等于头长度
            //{
            //    //IFileTools.MemCpy(headByte, recByte, 0, headByte.Length);
            //    //curRecLength += headByte.Length;



            //    //allDataLengh = IFileTools.ByteToInt(headByte) + headLength;

            //    //Debug.Log("Big   allDataLengh =="+ allDataLengh);
            //    //allRecData = new byte[allDataLengh];



            //    ////头考入
            //    //IFileTools.MemCpy(allRecData, 0, headByte, 0, headByte.Length);



            //    //// 剩下的 在放入
            //    //int tmpRemain = reallength -  headByte.Length;
            //    //if (tmpRemain > 0)
            //    //{
            //    //    byte[] tmpBytes = new byte[tmpRemain];
            //    //    IFileTools.MemCpy(tmpBytes, 0, recByte, headByte.Length, tmpRemain);
            //    //    RecevByte(tmpBytes, tmpRemain);
            //    //}



            //}
        }
Example #4
0
 private void RecvSmall(byte[] recvByte, int realLength)
 {
     IFileTools.MemCpy(allRecData, recvByte, curRecLength, realLength);
     curRecLength += realLength;
 }