public PacketStreamSystem(IUnreliablePacketSender packetSender, List <IPacketStreamReader> streamProcessors, List <IPacketStreamWriter> streamWriters, List <IPacketTransmissionNotificationReceiver> notificationReceivers)
 {
     _packetSender          = packetSender ?? throw new ArgumentNullException(nameof(packetSender));
     _streamProcessors      = streamProcessors ?? throw new ArgumentNullException(nameof(streamProcessors));
     _streamWriters         = streamWriters ?? throw new ArgumentNullException(nameof(streamWriters));
     _notificationReceivers =
         notificationReceivers ?? throw new ArgumentNullException(nameof(notificationReceivers));
     _log = NLogManager.Instance.GetLogger(this);
     _transmissionRecords       = new Queue <PacketTransmissionRecord>();
     _dataReceivedEvents        = new List <NetEvent>();
     _netWriter                 = new NetDataWriter(false, 1500);
     _remoteSeqAckFlag          = new SeqAckFlag();
     _transmissionNotifications = new List <bool>();
 }
 /// <summary>
 /// AckFlag must start at SeqLastNotified + 1
 /// All seqs in flag will be notified
 /// </summary>
 /// <param name="flag"></param>
 private void GenerateNotificationsFromAckFlagAndUpdateSeqLastNotified(SeqAckFlag flag)
 {
     // Notify based on the flag
     for (int seqBitPos = 0; seqBitPos < flag.SeqCount; seqBitPos++)
     {
         PacketTransmissionRecord record = _transmissionRecords.Dequeue();
         if (flag.IsAck(seqBitPos))
         {
             OnAckedTransmission(record);
         }
         _transmissionNotifications.Add(flag.IsAck(seqBitPos));
         _seqLastNotified = ++_seqLastNotified <= byte.MaxValue ? _seqLastNotified : 0;
     }
 }