Class EventStreamReader

java.lang.Object
com.styra.opa.openapi.utils.EventStreamReader
All Implemented Interfaces:
AutoCloseable

public final class EventStreamReader extends Object implements AutoCloseable
  • Constructor Details

    • EventStreamReader

      public EventStreamReader(InputStream in)
  • Method Details

    • readRawMessage

      public String readRawMessage() throws IOException
      Returns the event message (lines separated by \n) without the terminating \n\n. Returns null when end of stream reached (and may occur with a partially read event message that has not yet been terminated). Characters in comment lines are discarded as read (they are not buffered).
      Returns:
      the event message
      Throws:
      IOException
    • readMessage

      public Optional<EventStreamMessage> readMessage() throws IOException
      Throws:
      IOException
    • parseMessage

      public static EventStreamMessage parseMessage(String text)
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception