Пример #1
0
        private void ReceiveHead(byte[] buffer)
        {
            mSurplusLen     = 0;
            mSurplusInfoLen = 0;
            mProgress       = 0;

            byte  type = buffer[0];
            long  len  = BitConverter.ToInt64(buffer, 1);
            short info = BitConverter.ToInt16(buffer, HeadSize - 2);

            if (len > 0)
            {
                // Set Length
                mSurplusLen     = len;
                mSurplusInfoLen = info;

                // Parse receive packet
                ReceivePacket packet = mParser.ParseReceive(type, len);

                if (packet != null && packet.StartPacket())
                {
                    mReceivePacket = packet;

                    // Notifly
                    ReceiveDelivery delivery = mReceiveDelivery;
                    if (delivery != null)
                    {
                        delivery.PostReceiveStart(packet);
                    }
                }
                else
                {
                    // Set Null
                    mReceivePacket = null;
                }
            }

            ReceiveAsync(mSurplusInfoLen > 0 ? mSurplusInfoLen : mSurplusLen);
        }