object Comet

Helper function to produce a Comet using Pekko Streams.

Please see https://en.wikipedia.org/wiki/Comet_(programming) for details of Comet.

Example:

def streamClock() = Action {
  val df: DateTimeFormatter = DateTimeFormatter.ofPattern("HH mm ss")
  val tickSource = Source.tick(0 millis, 100 millis, "TICK")
  val source = tickSource.map((tick) => df.format(ZonedDateTime.now()))
  Ok.chunked(source via Comet.flow("parent.clockChanged"))
}
Source
Comet.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Comet
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. def flow(callbackName: String, initialChunk: ByteString = initialByteString, nonce: String = ""): Flow[ByteString, ByteString, NotUsed]

    Creates a flow of ByteString.

    Creates a flow of ByteString. Useful when you have objects that are not JSON or String where you may have to do your own conversion.

    Usage example:

    val htmlStream: Source[ByteString, ByteString, NotUsed] = Flow[Html].map { html =>
      ByteString.fromString(html.toString())
    }
    ...
    Ok.chunked(htmlStream via Comet.flow("parent.clockChanged"))
  2. def flow(callbackName: String, initialChunk: ByteString): Flow[ByteString, ByteString, NotUsed]

    Creates a flow of ByteString.

    Creates a flow of ByteString. Useful when you have objects that are not JSON or String where you may have to do your own conversion.

    Usage example:

    val htmlStream: Source[ByteString, ByteString, NotUsed] = Flow[Html].map { html =>
      ByteString.fromString(html.toString())
    }
    ...
    Ok.chunked(htmlStream via Comet.flow("parent.clockChanged"))
  3. val initialByteString: ByteString
  4. val initialHtmlChunk: Html
  5. def json(callbackName: String, nonce: String): Flow[JsValue, ByteString, NotUsed]

    Produces a flow of ByteString using Json.fromJson(_).get from a Flow of JsValue.

    Produces a flow of ByteString using Json.fromJson(_).get from a Flow of JsValue. Calls out to Comet.flow internally.

    callbackName

    the javascript callback method.

    nonce

    The CSP nonce to use for the script tag. If null no nonce will be sent.

    returns

    a flow of ByteString elements.

  6. def json(callbackName: String): Flow[JsValue, ByteString, NotUsed]

    Produces a flow of ByteString using Json.fromJson(_).get from a Flow of JsValue.

    Produces a flow of ByteString using Json.fromJson(_).get from a Flow of JsValue. Calls out to Comet.flow internally.

    callbackName

    the javascript callback method.

    returns

    a flow of ByteString elements.

  7. def string(callbackName: String, nonce: String): Flow[String, ByteString, NotUsed]

    Produces a Flow of escaped ByteString from a series of String elements.

    Produces a Flow of escaped ByteString from a series of String elements. Calls out to Comet.flow internally.

    callbackName

    the javascript callback method.

    nonce

    The CSP nonce to use for the script tag. If null no nonce will be sent.

    returns

    a flow of ByteString elements.

  8. def string(callbackName: String): Flow[String, ByteString, NotUsed]

    Produces a Flow of escaped ByteString from a series of String elements.

    Produces a Flow of escaped ByteString from a series of String elements. Calls out to Comet.flow internally.

    callbackName

    the javascript callback method.

    returns

    a flow of ByteString elements.