We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am currently playing with a small project where I do some CRUD operations and send events via SSE to clients when operations occur.
val (enumerator, channel) = Concurrent.broadcast[JsValue] def streamUpdates = Action { Ok.stream(enumerator &> EventSource()).as("text/event-stream") }
And exposing streamUpdates at say /GET //events is all that is needed. (Not sure what to do it the auto source controller is typed.
Then in the methods that do actions that you want to push you can do:
def update(id: BSONObjectID): EssentialAction = Action(parse.json){ request => Json.fromJson[JsObject](request.body)(reader).map{ t => Async{ res.update(id, t).map{ _ => val event = JsObject(List("type" -> JsString("update"), "data" -> t)) channel.push(event) Ok(Json.toJson(id)(idWriter)) } } }.recoverTotal{ e => BadRequest(JsError.toFlatJson(e)) } }
In JS you can then do: http://www.html5rocks.com/en/tutorials/eventsource/basics/ to react on updates.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am currently playing with a small project where I do some CRUD operations and send events via SSE to clients when operations occur.
And exposing streamUpdates at say /GET //events is all that is needed. (Not sure what to do it the auto source controller is typed.
Then in the methods that do actions that you want to push you can do:
In JS you can then do: http://www.html5rocks.com/en/tutorials/eventsource/basics/ to react on updates.
The text was updated successfully, but these errors were encountered: