public abstract class Comet extends Object
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 Flow<ByteString,ByteString,NotUsed> |
flow(String callbackName)
Produces a flow of ByteString with a prepended block and a script wrapper.
|
static Flow<com.fasterxml.jackson.databind.JsonNode,ByteString,NotUsed> |
json(String callbackName)
Produces a flow of ByteString using `Json.stringify` from a Flow of JsonNode.
|
static Flow<String,ByteString,NotUsed> |
string(String callbackName)
Produces a Flow of escaped ByteString from a series of String elements.
|
public static Flow<String,ByteString,NotUsed> string(String callbackName)
callbackName - the javascript callback method.public static Flow<com.fasterxml.jackson.databind.JsonNode,ByteString,NotUsed> json(String callbackName)
callbackName - the javascript callback method.public static Flow<ByteString,ByteString,NotUsed> flow(String callbackName)
callbackName - the javascript callback method.