Skip to content

Instantly share code, notes, and snippets.

@dat-vikash
Created April 2, 2015 14:52
Show Gist options
  • Save dat-vikash/2ae6abfc9e6cf70c7660 to your computer and use it in GitHub Desktop.
Save dat-vikash/2ae6abfc9e6cf70c7660 to your computer and use it in GitHub Desktop.
Play 2.2.x WebSocketChannel trait
/* This trait allows websocket classes to push messages to client via a concurrent channel */
trait WebSocketChannel
{
//instantiate an Enumerator and Channel
val (out,channel) = Concurrent.broadcast[JsValue]
// method to allow pushing of data up the channel
def push(data: JsValue) = channel.push(data)
def cleanSocketResources() = channel.end()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment