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);
}
}
}