Skip to content

Instantly share code, notes, and snippets.

@lucastorri
Created February 10, 2012 21:16
Show Gist options
  • Save lucastorri/1792941 to your computer and use it in GitHub Desktop.
Save lucastorri/1792941 to your computer and use it in GitHub Desktop.
Simple echo Controller in Play framework 2.0
package controllers
import play.api.libs.iteratee._
object Application extends Controller {
def echo = WebSocket.using[String] { request =>
val out = Enumerator.imperative[String]()
val in = Iteratee.foreach[String](out.push(_)).mapDone(_ => println("Disconnected"))
(in, out)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment