Skip to content

Instantly share code, notes, and snippets.

@atamborrino
Last active December 10, 2015 01:38
Show Gist options
  • Save atamborrino/4360663 to your computer and use it in GitHub Desktop.
Save atamborrino/4360663 to your computer and use it in GitHub Desktop.
Play 2.1 - Using Concurrent.PatchPannel
def stream = WebSocket.using[JsValue] { req =>
val out = Concurrent.patchPanel[JsValue] { patcher =>
// callback called when the enumerator "out" is applied to an iteratee, here the
// Websocket output Iteratee
patcher.patchIn(streamEnumerator1)
// ...
patcher.patchIn(streamEnumerator2)
}
val in = Iteratee.foreach[JsValue] { json =>
val topic = // read json and get the topic that the user want to subscribe to
} mapDone { _ => println("Disconnected") }
(in, out)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment