Package 

Class BaseStreamReceiver

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final Flow<T> flow
    • Method Summary

      Modifier and Type Method Description
      abstract Flow<T> getFlow() A Flow of stream data as it arrives.
      final T readNext() Suspends and waits for the next piece of data.
      final List<T> readAll() Suspends and waits for all available data until the stream is closed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BaseStreamReceiver

        BaseStreamReceiver(Channel<ByteArray> source)
    • Method Detail

      • getFlow

         abstract Flow<T> getFlow()

        A Flow of stream data as it arrives.

        Collect this flow to process incoming data incrementally. The flow completes normally when the stream receives all the data without error. If the stream ends abnormally, the flow fails with a StreamException after all buffered chunks have been emitted.

        Example:

        reader.flow
            .catch { e ->
                if (e is StreamException) {
                    handleStreamError(e)
                } else {
                    throw e
                }
            }
            .collect { chunk -> process(chunk) }
      • readNext

         final T readNext()

        Suspends and waits for the next piece of data.

      • readAll

         final List<T> readAll()

        Suspends and waits for all available data until the stream is closed.