public abstract class SseEventReader extends Object
Constructor and Description |
---|
SseEventReader() |
Modifier and Type | Method and Description |
---|---|
abstract CharSequence |
getData()
Returns the payload of the last received event.
|
abstract String |
getName()
Returns the name of the last received event.
|
abstract SseEventType |
getType()
Returns the
SseEventType of the already received event. |
abstract SseEventType |
next()
Invoking this method will cause the thread to block until an event is
received.
|
public abstract CharSequence getData() throws IOException
next()
ONLY
if the returned type is SseEventType.DATA
. Otherwise, an
IOException is thrown.
If next()
returns any other event type, then subsequent
invocation of this method returns a null.
IOException
- if the event type is not SseEventType.DATApublic abstract String getName()
next()
.
It's perfectly legal for an event name to be null even if it contains
data. Similarly, it is perfectly legal for an event of type
SseEvent#EMPTY
to have an event name.
public abstract SseEventType getType()
SseEventType
of the already received event. This
method returns a null until the first event is received. Note that
this is not a blocking call. When connected, if this method is invoked
immediately after next()
, then they will return the same value.
Based on the returned SseEventType
, the application developer can
decide whether to read the data. This method will continue to return the
same SseEventType
till the next event arrives. When the next
event arrives, this method will return the the SseEventType
associated with that event.
public abstract SseEventType next() throws IOException
SseEventType
, the application
developer can decide whether to invoke the #readData()
method.
When the connection is closed, this method returns
SseEventType.EOS
.
An IOException is thrown if this method is invoked before the connection has been established.
IOException
- if invoked before the connection is establishedCopyright © 2014. All Rights Reserved.