Flush() public method

public Flush ( H2NBinaryWriter writer, ulong stage, byte flags, bool header, N2HBinaryReader reader, ushort size ) : void
writer H2NBinaryWriter
stage ulong
flags byte
header bool
reader N2HBinaryReader
size ushort
return void
Beispiel #1
0
 public void Flush()
 {
     if (_audioWriter != null)
     {
         _audioWriter.Flush();
     }
     if (_videoWriter != null)
     {
         _videoWriter.Flush();
     }
     _writer.Flush(true);
 }
Beispiel #2
0
        public void Commit()
        {
            uint size     = 0;
            var  lost     = new List <ulong>();
            var  current  = Stage;
            uint count    = 0;
            var  it       = _fragments.OrderBy(x => x.Stage).GetEnumerator();
            var  isNotEnd = it.MoveNext();

            while (isNotEnd)
            {
                current = it.Current.Stage - current - 2;
                size   += H2NBinaryWriter.Get7BitValueSize(current);
                lost.Add(current);
                current = it.Current.Stage;
                while ((isNotEnd = it.MoveNext()) && it.Current.Stage == (++current))
                {
                    ++count;
                }
                size += H2NBinaryWriter.Get7BitValueSize(count);
                lost.Add(count);
                --current;
                count = 0;
            }
            var bufferSize = _packet == null ? 0x7F : (_packet.Fragments > 0x3F00 ? 0 : 0x3F00 - _packet.Fragments);

            if (string.IsNullOrEmpty(Writer.Signature))
            {
                bufferSize = 0;
            }
            var ack = Band.WriteMessage(0x51,
                                        (ushort)(H2NBinaryWriter.Get7BitValueSize(Id) + H2NBinaryWriter.Get7BitValueSize(bufferSize) +
                                                 H2NBinaryWriter.Get7BitValueSize(Stage) + size));
            var pos = ack.BaseStream.Position;

            ack.Write7BitLongValue(Id);
            ack.Write7BitValue(bufferSize);
            ack.Write7BitLongValue(Stage);
            //Debug.Write($"commit:{Id},stage:{Stage},writerId:{Writer.Id}");
            foreach (var l in lost)
            {
                //Debug.Write("lost"+l);
                ack.Write7BitLongValue(l);
            }
            // Debug.WriteLine("");
            CommitHandler();
            Writer.Flush();
        }
 public void Flush()
 {
     _audioWriter?.Flush();
     _videoWriter?.Flush();
     Writer.Flush(true);
 }