public abstract class Comet extends Results.Chunks<java.lang.String>
Comet.string
and Comet.json
. These methods build on top of the base method, Comet.flow
,
which takes a Flow of akka.util.ByteString
and organizes it into Comet format.
public Result liveClock() { final DateTimeFormatter df = DateTimeFormatter.ofPattern("HH mm ss"); final Source tickSource = Source.tick(Duration.Zero(), Duration.create(100, MILLISECONDS), "TICK"); final Source eventSource = tickSource.map((tick) -> df.format(ZonedDateTime.now())); final Source<ByteString, NotUsed> flow = eventSource.via(Comet.string("parent.clockChanged")); return ok().chunked(flow).as(Http.MimeTypes.HTML); }
Results.Chunks.Out<A>
Constructor and Description |
---|
Comet(java.lang.String callbackMethod)
Deprecated.
Please use
Comet.string or Comet.json , since 2.5.x |
Modifier and Type | Method and Description |
---|---|
void |
close()
Deprecated.
|
static akka.stream.javadsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed> |
flow(java.lang.String callbackName)
Produces a flow of ByteString with a prepended block and a script wrapper.
|
protected java.lang.String |
initialBuffer()
Deprecated.
|
static akka.stream.javadsl.Flow<com.fasterxml.jackson.databind.JsonNode,akka.util.ByteString,akka.NotUsed> |
json(java.lang.String callbackName)
Produces a flow of ByteString using `Json.stringify` from a Flow of JsonNode.
|
abstract void |
onConnected()
Deprecated.
|
void |
onDisconnected(java.lang.Runnable callback)
Deprecated.
|
void |
onReady(Results.Chunks.Out<java.lang.String> out)
Deprecated.
|
void |
sendMessage(com.fasterxml.jackson.databind.JsonNode message)
Deprecated.
|
void |
sendMessage(java.lang.String message)
Deprecated.
|
static akka.stream.javadsl.Flow<java.lang.String,akka.util.ByteString,akka.NotUsed> |
string(java.lang.String callbackName)
Produces a Flow of escaped ByteString from a series of String elements.
|
static Comet |
whenConnected(java.lang.String jsMethod,
java.util.function.Consumer<Comet> callback)
Deprecated.
|
@Deprecated public Comet(java.lang.String callbackMethod)
Comet.string
or Comet.json
, since 2.5.xcallbackMethod
- The Javascript callback method to call on each message.public static akka.stream.javadsl.Flow<java.lang.String,akka.util.ByteString,akka.NotUsed> string(java.lang.String callbackName)
callbackName
- the javascript callback method.public static akka.stream.javadsl.Flow<com.fasterxml.jackson.databind.JsonNode,akka.util.ByteString,akka.NotUsed> json(java.lang.String callbackName)
callbackName
- the javascript callback method.public static akka.stream.javadsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed> flow(java.lang.String callbackName)
callbackName
- the javascript callback method.@Deprecated 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 protected java.lang.String initialBuffer()
@Deprecated public void sendMessage(java.lang.String message)
@Deprecated public void sendMessage(com.fasterxml.jackson.databind.JsonNode message)
@Deprecated public abstract void onConnected()
@Deprecated public void onDisconnected(java.lang.Runnable callback)
@Deprecated public void close()
@Deprecated public static Comet whenConnected(java.lang.String jsMethod, java.util.function.Consumer<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