public abstract class Comet
extends java.lang.Object
There are two methods that can be used to convert strings and JSON, 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); }
Constructor and Description |
---|
Comet() |
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
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.
|
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.