OnReceiveNotification() private method

Processes a notification and updates our ack counter. Return true iff the notification is new.
private OnReceiveNotification ( long curTime, ushort notificationSeq ) : bool
curTime long
notificationSeq ushort
return bool
示例#1
0
        private void HandleCarrier(
            NetPeer peer,
            byte[] buffer,
            int length)
        {
            if (peer.IsConnected == false)
            {
                return;
            }

            // Read the carrier and notifications
            ushort notificationAck;
            ushort notificationSeq;

            this.reusableQueue.Clear();
            bool success =
                NetEncoding.ReadCarrier(
                    this.CreateEvent,
                    peer,
                    buffer,
                    length,
                    out notificationAck,
                    out notificationSeq,
                    this.reusableQueue);

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

            long curTime = this.Time;

            peer.OnReceiveCarrier(curTime, notificationAck, this.RecycleEvent);

            // The packet contains the first sequence number. All subsequent
            // notifications have sequence numbers in order, so we just increment.
            foreach (NetEvent notification in this.reusableQueue)
            {
                if (peer.OnReceiveNotification(curTime, notificationSeq++))
                {
                    this.eventOut.Enqueue(notification);
                }
            }
        }