public abstract class EventSource extends Results.Chunks<java.lang.String>
Results.Chunks.Out<A>
Constructor and Description |
---|
EventSource()
Create a new EventSource socket
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the channel
|
abstract void |
onConnected()
The socket is ready, you can start sending messages.
|
void |
onDisconnected(F.Callback0 callback)
Add a callback to be notified when the client has disconnected.
|
void |
onReady(Results.Chunks.Out<java.lang.String> out)
Called when the Chunked stream is ready.
|
void |
sendData(java.lang.String data)
Sending a generic event.
|
void |
sendDataById(java.lang.String eventId,
java.lang.String data)
Setting an ID lets the browser keep track of the last event fired so that if, the connection to the server is dropped,
a special HTTP header (Last-Event-ID) is set with the new request.
|
void |
sendDataByName(java.lang.String eventName,
java.lang.String data)
A single event source can generate different types events by including an event name.
|
public void onReady(Results.Chunks.Out<java.lang.String> out)
Results.Chunks
onReady
in class Results.Chunks<java.lang.String>
out
- The out stream.public void sendDataByName(java.lang.String eventName, java.lang.String data)
eventName
- Unique name of the event.data
- data associated with eventpublic void sendDataById(java.lang.String eventId, java.lang.String data)
eventId
- Unique event id.data
- data associated with eventpublic void sendData(java.lang.String data)
data
- data associated with eventpublic abstract void onConnected()
public void onDisconnected(F.Callback0 callback)
public void close()