コード例 #1
0
        private bool Validate(byte[] buffer, int msgLength)
        {
            // Recalculate CRC64 and check against checksum in the head
            var   decoder       = new Decoder(buffer, 0);
            ulong receivedCrc   = decoder.Decode64U();
            ulong calculatedCrc = Crc64.Compute(buffer, decoder.Position, msgLength - decoder.Position);

            return(receivedCrc == calculatedCrc);
        }
コード例 #2
0
        private void SendWithChecksum(byte [] data, int length)
        {
            // add a CRC64 checksum in the reserved space
            ulong crc     = Crc64.Compute(data, RESERVED, length - RESERVED);
            var   encoder = new Encoder(data, 0);

            encoder.Encode64U(crc);
            RawSend(data, length);

            if (kcp.WaitSnd > 1000)
            {
                Debug.LogWarningFormat("Too many packets waiting in the send queue {0}, you are sending too much data,  the transport can't keep up", kcp.WaitSnd);
            }
        }