public abstract class EventSource extends Results.Chunks<java.lang.String>
Modifier and Type | Class and Description |
---|---|
static class |
EventSource.Event
Utility class to build events.
|
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 |
send(EventSource.Event event)
Send an event.
|
static EventSource |
whenConnected(F.Callback<EventSource> callback)
Creates an EventSource.
|
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 send(EventSource.Event event)
event
- Event contentpublic abstract void onConnected()
public void onDisconnected(F.Callback0 callback)
public void close()
public static EventSource whenConnected(F.Callback<EventSource> callback)
onConnected
method is
implemented using the specified F.Callback<EventSource>
and
is invoked with EventSource.this
.callback
- the callback used to implement onConnectedjava.lang.NullPointerException
- if the specified callback is null