play.libs
Class Comet

java.lang.Object
  extended by play.mvc.Results.Chunks<java.lang.String>
      extended by play.libs.Comet

public abstract class Comet
extends Results.Chunks<java.lang.String>

A Chunked stream sending Comet messages.


Nested Class Summary
 
Nested classes/interfaces inherited from class play.mvc.Results.Chunks
Results.Chunks.Out<A>
 
Constructor Summary
Comet(java.lang.String callbackMethod)
          Create a new Comet socket
 
Method Summary
 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).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Comet

public Comet(java.lang.String callbackMethod)
Create a new Comet socket

Parameters:
callbackMethod - The Javascript callback method to call on each message.
Method Detail

onReady

public void onReady(Results.Chunks.Out<java.lang.String> out)
Description copied from class: Results.Chunks
Called when the Chunked stream is ready.

Specified by:
onReady in class Results.Chunks<java.lang.String>
Parameters:
out - The out stream.

initialBuffer

protected java.lang.String initialBuffer()
Initial chunk of data to send for browser compatibility (default to send 5Kb of blank data).


sendMessage

public void sendMessage(java.lang.String message)
Send a message on this socket (will be received as String in the Javascript callback method).


sendMessage

public 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).


onConnected

public abstract void onConnected()
The socket is ready, you can start sending messages.


onDisconnected

public void onDisconnected(F.Callback0 callback)
Add a callback to be notified when the client has disconnected.


close

public void close()
Close the channel