/** * @return a flow of EventSource.Event to ByteString. */ public static Flow<EventSource.Event, ByteString, ?> flow() { Flow<Event, Event, NotUsed> flow = Flow.of(Event.class); return flow.map((EventSource.Event event) -> ByteString.fromString(event.formatted())); }
/** * @return a flow of EventSource.Event to ByteString. */ public static Flow<EventSource.Event, ByteString, ?> flow() { Flow<Event, Event, NotUsed> flow = Flow.of(Event.class); return flow.map((EventSource.Event event) -> ByteString.fromString(event.formatted())); }
/** * @return a flow of EventSource.Event to ByteString. */ public static Flow<EventSource.Event, ByteString, ?> flow() { Flow<Event, Event, NotUsed> flow = Flow.of(Event.class); return flow.map((EventSource.Event event) -> ByteString.fromString(event.formatted())); }
/** * Produces a Flow of escaped ByteString from a series of String elements. Calls * out to Comet.flow internally. * * @param callbackName the javascript callback method. * @return a flow of ByteString elements. */ public static Flow<String, ByteString, NotUsed> string(String callbackName) { return Flow.of(String.class).map(str -> { return ByteString.fromString("'" + StringEscapeUtils.escapeEcmaScript(str) + "'"); }).via(flow(callbackName)); }
/** * Produces a Flow of escaped ByteString from a series of String elements. Calls * out to Comet.flow internally. * * @param callbackName the javascript callback method. * @return a flow of ByteString elements. */ public static Flow<String, ByteString, NotUsed> string(String callbackName) { return Flow.of(String.class).map(str -> { return ByteString.fromString("'" + StringEscapeUtils.escapeEcmaScript(str) + "'"); }).via(flow(callbackName)); }
/** * Produces a flow of ByteString using `Json.stringify` from a Flow of JsonNode. Calls * out to Comet.flow internally. * * @param callbackName the javascript callback method. * @return a flow of ByteString elements. */ public static Flow<JsonNode, ByteString, NotUsed> json(String callbackName) { return Flow.of(JsonNode.class).map(json -> { return ByteString.fromString(Json.stringify(json)); }).via(flow(callbackName)); }
/** * Produces a flow of ByteString using `Json.stringify` from a Flow of JsonNode. Calls * out to Comet.flow internally. * * @param callbackName the javascript callback method. * @return a flow of ByteString elements. */ public static Flow<JsonNode, ByteString, NotUsed> json(String callbackName) { return Flow.of(JsonNode.class).map(json -> { return ByteString.fromString(Json.stringify(json)); }).via(flow(callbackName)); }
/** * Produces a flow of ByteString with a prepended block and a script wrapper. * * @param callbackName the javascript callback method. * @return a flow of ByteString elements. */ public static Flow<ByteString, ByteString, NotUsed> flow(String callbackName) { ByteString cb = ByteString.fromString(callbackName); return Flow.of(ByteString.class).map((msg) -> { return formatted(cb, msg); }).prepend(Source.single(initialChunk)); }
/** * Produces a Flow of escaped ByteString from a series of String elements. Calls * out to Comet.flow internally. * * @param callbackName the javascript callback method. * @return a flow of ByteString elements. */ public static Flow<String, ByteString, NotUsed> string(String callbackName) { return Flow.of(String.class).map(str -> { return ByteString.fromString("'" + StringEscapeUtils.escapeEcmaScript(str) + "'"); }).via(flow(callbackName)); }
/** * Produces a flow of ByteString using `Json.stringify` from a Flow of JsonNode. Calls * out to Comet.flow internally. * * @param callbackName the javascript callback method. * @return a flow of ByteString elements. */ public static Flow<JsonNode, ByteString, NotUsed> json(String callbackName) { return Flow.of(JsonNode.class).map(json -> { return ByteString.fromString(Json.stringify(json)); }).via(flow(callbackName)); }
/** * Produces a flow of ByteString with a prepended block and a script wrapper. * * @param callbackName the javascript callback method. * @return a flow of ByteString elements. */ public static Flow<ByteString, ByteString, NotUsed> flow(String callbackName) { ByteString cb = ByteString.fromString(callbackName); return Flow.of(ByteString.class).map((msg) -> { return formatted(cb, msg); }).prepend(Source.single(initialChunk)); }
/** * Produces a flow of ByteString with a prepended block and a script wrapper. * * @param callbackName the javascript callback method. * @return a flow of ByteString elements. */ public static Flow<ByteString, ByteString, NotUsed> flow(String callbackName) { ByteString cb = ByteString.fromString(callbackName); return Flow.of(ByteString.class).map((msg) -> { return formatted(cb, msg); }).prepend(Source.single(initialChunk)); }