playframework - How execute code after returning result in Play framework -


how execute code after returning result client? example:

return ok("first"); 

after need send response websocket actor

myactor.tell("second",null) 

main goal - need send message socket after sending response

you can't directly, return statements ends action.

if problem long rendering of template, can render first, send message , send pre-rendered result, like

result res = ok("first"); myactor.tell("second",null); return res; 

if doesn't satisfy still, can use akka scheduler schedule message let's 1 second delay. (check akka's documentations details)

finally can send content , message @ once within current result i.e. wrapping within json object, or adding message response header - of course if you're handling js on client side.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -