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.
|
void |
sendData(java.lang.String data)
Deprecated.
Replaced by send
|
void |
sendDataById(java.lang.String eventId,
java.lang.String data)
Deprecated.
Replaced by send
|
void |
sendDataByName(java.lang.String eventName,
java.lang.String data)
Deprecated.
Replaced by send
|
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.@Deprecated public void sendDataByName(java.lang.String eventName, java.lang.String data)
eventName
- Unique name of the event.data
- data associated with eventsend(play.libs.EventSource.Event)
@Deprecated public void sendDataById(java.lang.String eventId, java.lang.String data)
eventId
- Unique event id.data
- data associated with eventsend(play.libs.EventSource.Event)
@Deprecated public void sendData(java.lang.String data)
data
- data associated with eventsend(play.libs.EventSource.Event)
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