private OnReceiveCarrier ( long curTime, ushort notificationAck, Action |
||
curTime | long | |
notificationAck | ushort | |
deallocate | Action |
|
return | void |
public void TestReliableCleanup() { NetPeer netPeer = new NetPeer(null, "Token", false, 0); for (int i = 0; i < 20; i++) netPeer.QueueNotification(new NetEvent()); netPeer.OnReceiveCarrier(0, 10, (x) => x = null); // First sequence number is 1, so we should have 10 remaining Assert.AreEqual(10, netPeer.Outgoing.Count()); }
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); } } }