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
Post a Comment