Skip to content

Instantly share code, notes, and snippets.

@jto
Forked from playxamplez-admin/CODE
Last active December 20, 2015 03:39
Show Gist options
  • Save jto/6065207 to your computer and use it in GitHub Desktop.
Save jto/6065207 to your computer and use it in GitHub Desktop.
Very simple #ServerSentEvent (#SSE) example
package controllers
import play.api.mvc._
import play.api.libs.EventSource
import play.api.libs.iteratee._
object Application extends Controller {
val events = Enumerator.repeat("0")
def index = Action {
Ok.stream((events &> Enumeratee.take(10) &> EventSource()) >>> Enumerator.eof)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment