MiniUDP.NetPeer.OnReceivePayload C# (CSharp) Method

OnReceivePayload() private method

Logs the payload's sequence ID to record payload packet loss. Returns true if we should accept the payload, false if it's too old.
private OnReceivePayload ( long curTime, ushort sequence ) : bool
curTime long
sequence ushort
return bool
        internal bool OnReceivePayload(long curTime, ushort sequence)
        {
            return this.traffic.OnReceivePayload(curTime, sequence);
        }

Usage Example

Esempio n. 1
0
        private void HandlePayload(
            NetPeer peer,
            byte[] buffer,
            int length)
        {
            if (peer.IsConnected == false)
            {
                return;
            }

            // Read the payload
            bool success =
                NetEncoding.ReadPayload(
                    CreateEvent,
                    peer,
                    buffer,
                    length,
                    out ushort payloadSeq,
                    out NetEvent evnt);

            // Validate
            if (success == false)
            {
                NetDebug.LogError("Error reading payload");
                return;
            }

            // Enqueue the event for processing if the peer can receive it
            if (peer.OnReceivePayload(Time, payloadSeq))
            {
                eventOut.Enqueue(evnt);
            }
        }