Class EventStreamReader

  • Direct Known Subclasses:
    OkHttpEventStream

    public abstract class EventStreamReader
    extends Object
    Interpreter for server-sent events. See https://www.w3.org/TR/2009/WD-eventsource-20090421/#event-stream-interpretation for information on processing.
    • Method Detail

      • isOpen

        protected abstract boolean isOpen()
                                   throws IOException
        Whether or not the stream is still active.
        Returns:
        true if active, false if not
        Throws:
        IOException - if a stream is in the wrong state, IO errors can be thrown
      • readLine

        protected abstract String readLine()
                                    throws IOException
        Read the next line of a stream from a given source.
        Returns:
        the next utf8 line
        Throws:
        IOException - if a stream is in the wrong state, IO errors can be thrown
      • processEvent

        protected final Event processEvent()
                                    throws IOException
        Process the next event in a given stream.
        Returns:
        the fully processed event
        Throws:
        IOException - if a stream is in the wrong state, IO errors can be thrown