Beispiel #1
0
 public static ISubject <ManagedBuffer, ManagedBuffer> ToBytesSubject(this Stream stream, BufferManager bufferManager, int bufferSize, CancellationToken token)
 {
     return
         (stream.ToSubject <Stream, ManagedBuffer, ManagedBuffer>(
              (s, t) => ManagedBuffer.ReadAsync(s, bufferManager, bufferSize, t),
              IsSocketClosed,
              buf => buf == null,
              async(s, content) =>
     {
         await content.WriteAsync(s, token);
         content.Dispose();
     },
              _ => stream.Close(),
              stream.Close));
 }
Beispiel #2
0
 public static ISubject <ManagedBuffer, ManagedBuffer> ToFrameSubject(this Stream stream, BufferManager bufferManager, Func <Exception, bool> isCompleted, CancellationToken token)
 {
     return
         (stream.ToSubject <Stream, ManagedBuffer, ManagedBuffer>(
              (s, t) => ManagedBuffer.ReadFrameAsync(s, bufferManager, t),
              isCompleted,
              buf => buf == null,
              async(s, content) =>
     {
         await content.WriteFrameAsync(s, token);
         content.Dispose();
     },
              _ => stream.Close(),
              stream.Close));
 }