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:
Closeable,AutoCloseable,Iterator<String>,EventSource<String>
- Enclosing class:
HttpClient
class HttpClient.ServerSentEventsReader
extends HttpClient.ChunkedLineReader
implements EventSource<String>
-
Nested Class Summary
Nested classes/interfaces inherited from interface one.nio.http.EventSource
EventSource.Event<D> -
Field Summary
FieldsFields inherited from class one.nio.http.HttpClient.ResponseReader
buf, length, pos, socket -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()poll()Waits for the next SSE and returns an event.private HttpClient.EventImpl(package private) EventSourceResponsereadResponse(int method) Methods inherited from class one.nio.http.HttpClient.ChunkedLineReader
hasNext, nextMethods inherited from class one.nio.http.HttpClient.ResponseReader
mergeChunks, readBody, readBodyUntilClose, readChunkedBody, readLine, readResponseBody, readResponseHeaders, readResultCodeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Field Details
-
keepAlive
private boolean keepAlive
-
-
Constructor Details
-
ServerSentEventsReader
ServerSentEventsReader(Socket socket, int bufferSize) throws IOException - Throws:
IOException
-
-
Method Details
-
readResponse
- Overrides:
readResponsein classHttpClient.ResponseReader- Throws:
IOExceptionHttpException
-
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<String>- Returns:
- the next event from the stream or null, if stream was closed by either party
-
readEvent
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classHttpClient.ChunkedLineReader
-