public bool WriteUpdatePayload(IOutOctetStream octetStream) { var canSendUpdatePacket = tendOut.CanIncrementOutgoingSequence; pendingOutSequenceNumberUsed = false; if (canSendUpdatePacket) { outgoingSequenceNumber = outgoingSequenceNumber.Next(); pendingOutSequenceNumber = outgoingSequenceNumber; pendingOutSequenceNumberUsed = true; var tendSequenceId = tendOut.IncreaseOutgoingSequenceId(); WriteHeader(octetStream, NormalMode, outgoingSequenceNumber.Value, connectionId); TendSerializer.Serialize(octetStream, tendIn, tendOut); var now = monotonicClock.NowMilliseconds(); timestampedHistory.SentPacket(outgoingSequenceNumber, now, log); if (useDebugLogging) { log.Trace($"SendOneUpdatePacket: tendSeq{tendSequenceId}"); } return(true); } WritePing(octetStream); return(false); }
public void Enqueue(SequenceId sequenceId, bool wasReceived) { if (sequenceId.Value != expectedSequenceId.Value) { throw new Exception($"wrong packet notification. Expected {expectedSequenceId} but received {sequenceId}"); } var info = new PacketReceivedNotification { SequenceId = sequenceId, WasReceived = wasReceived }; queue.Enqueue(info); expectedSequenceId = expectedSequenceId.Next(); }