I’m stuck on how to proceed. I’m trying to use the play 1.2.5 framework with a 3rd party API (Interactive Brokers).
I know someone answered a similar question for Grails Java : How to achieve socket programming functionality with 3rd party API
basically, IB API uses asynchronous communication for requests and replies. i.e. when i call getData(), the API knows to use the callback function dataResults() when it is ready to send them. In order for dataResults() to be callable, the broker object I created still needs to be around to receive the reply.
Inside a controller function, if i create a broker object and call getData(), when the request finishes, the broker object obviously also disappears. So I’ll never be able to receive the reply.
any ideals on how to do this in Play? any help would be much appreciated.
thanks
Have you considered using the play’s built-in support for asynchronous work?
http://www.playframework.org/documentation/1.2.5/asynchronous
or if you are considering version 2 of the framework, you may see the differences at:
http://playframework.org/documentation/2.0.3/JavaAsync
This may help to solve your issue but of course there is always the statics route if you need to persist the object for a longer period of time.