Package one.nio.http
Class HttpClient.ServerSentEventsReader
- java.lang.Object
-
- one.nio.http.HttpClient.ResponseReader
-
- one.nio.http.HttpClient.ChunkedLineReader
-
- one.nio.http.HttpClient.ServerSentEventsReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.util.Iterator<java.lang.String>,EventSource<java.lang.String>
- Enclosing class:
- HttpClient
class HttpClient.ServerSentEventsReader extends HttpClient.ChunkedLineReader implements EventSource<java.lang.String>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface one.nio.http.EventSource
EventSource.Event<D>
-
-
Constructor Summary
Constructors Constructor Description ServerSentEventsReader(Socket socket, int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()EventSource.Event<java.lang.String>poll()Waits for the next SSE and returns an event.private HttpClient.EventImplreadEvent(java.lang.String line)(package private) EventSourceResponsereadResponse(int method)-
Methods inherited from class one.nio.http.HttpClient.ChunkedLineReader
hasNext, next
-
Methods inherited from class one.nio.http.HttpClient.ResponseReader
mergeChunks, readBody, readBodyUntilClose, readChunkedBody, readLine, readResponseBody, readResponseHeaders, readResultCode
-
-
-
-
Constructor Detail
-
ServerSentEventsReader
ServerSentEventsReader(Socket socket, int bufferSize) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
readResponse
EventSourceResponse readResponse(int method) throws java.io.IOException, HttpException
- Overrides:
readResponsein classHttpClient.ResponseReader- Throws:
java.io.IOExceptionHttpException
-
poll
public EventSource.Event<java.lang.String> poll()
Description copied from interface:EventSourceWaits for the next SSE and returns an event. The method can block for a long time ( determined by server ). It is essential to check for null andEventSource.Event.isEmpty()before processing- Specified by:
pollin interfaceEventSource<java.lang.String>- Returns:
- the next event from the stream or null, if stream was closed by either party
-
readEvent
private HttpClient.EventImpl readEvent(java.lang.String line)
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classHttpClient.ChunkedLineReader
-
-