public abstract class Comet extends Results.Chunks<java.lang.String>
Results.Chunks.Out<A>
Constructor and Description |
---|
Comet(java.lang.String callbackMethod)
Create a new Comet socket
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the channel
|
protected java.lang.String |
initialBuffer()
Initial chunk of data to send for browser compatibility (default to send 5Kb of blank data).
|
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 |
sendMessage(com.fasterxml.jackson.databind.JsonNode message)
Send a Json message on this socket (will be received as Json in the Javascript callback method).
|
void |
sendMessage(java.lang.String message)
Send a message on this socket (will be received as String in the Javascript callback method).
|
static Comet |
whenConnected(java.lang.String jsMethod,
F.Callback<Comet> callback)
Creates a Comet.
|
public Comet(java.lang.String callbackMethod)
callbackMethod
- The Javascript callback method to call on each message.public void onReady(Results.Chunks.Out<java.lang.String> out)
Results.Chunks
onReady
in class Results.Chunks<java.lang.String>
out
- The out stream.protected java.lang.String initialBuffer()
public void sendMessage(java.lang.String message)
public void sendMessage(com.fasterxml.jackson.databind.JsonNode message)
public abstract void onConnected()
public void onDisconnected(F.Callback0 callback)
public void close()
public static Comet whenConnected(java.lang.String jsMethod, F.Callback<Comet> callback)
onConnected
method is
implemented using the specified Callback<Comet>
and
is invoked with Comet.this
.jsMethod
- the Javascript method to call on each messagecallback
- the callback used to implement onConnectedjava.lang.NullPointerException
- if the specified callback is null