Object

play.api.libs

Comet

Related Doc: package libs

Permalink

object Comet

Helper function to produce a Comet using Akka 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. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. def flow(callbackName: String, initialChunk: ByteString = initialByteString): Flow[ByteString, ByteString, NotUsed]

    Permalink

    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"))
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. val initialByteString: ByteString

    Permalink
  13. val initialHtmlChunk: Html

    Permalink
  14. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  15. def json(callbackName: String): Flow[JsValue, ByteString, NotUsed]

    Permalink

    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.

  16. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. def string(callbackName: String): Flow[String, ByteString, NotUsed]

    Permalink

    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.

  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  21. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  22. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def apply[E](callback: String, initialChunk: Html = initialHtmlChunk): Enumeratee[E, Html]

    Permalink

    Create a Comet Enumeratee.

    Create a Comet Enumeratee.

    E

    Type of messages handled by this comet stream.

    callback

    Javascript function to call on the browser for each message.

    initialChunk

    Initial chunk of data to send for browser compatibility (default to send 5Kb of blank data)

    Annotations
    @deprecated
    Deprecated

    (Since version 2.5.0) Please use Comet.flow

Inherited from AnyRef

Inherited from Any

Ungrouped