コード例 #1
0
        private void IncommingBytesToPackets(byte[] bytes, int numBytes)
        {
            byte[] cheatArray = new byte[numBytes];// this is a terrible temp solution
            Buffer.BlockCopy(bytes, 0, cheatArray, 0, numBytes);
            //Console.WriteLine("Received: " + BitConverter.ToString(cheatArray));
            int bytesParsed          = 0;
            List <BasePacket> dataIn = IntrepidSerialize.Deserialize(cheatArray, numBytes, ref bytesParsed);

            lock (packetsReceived)
            {
                dataIn.ForEach((bp) => { packetsReceived.Enqueue(bp); });
            }

            if (bytesParsed < numBytes)
            {
                int numBytesUnParsed = numBytes - bytesParsed;
                Buffer.BlockCopy(cheatArray, bytesParsed, readBuffer, 0, numBytesUnParsed);
                readBufferOffset = numBytesUnParsed;
            }
            else
            {
                readBufferOffset = 0;
            }
        }