Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Handling many HTTPService calls, and waiting for all results (in order)  (Read 9609 times)
99miles
Jr. Member
**
Posts: 14


View Profile WWW Email
« on: September 16, 2009, 06:04:32 »


I'm looking for the best (or at least a good) way to handle the following:

I need to call one HTTPService many times, and wait for all the results, and put them in order.

The reason is, I have a path of coordinates, and for each I call a service to get the elevation of that point. Once I have them all I will chart them, so they need to be in order of the path.

Thanks in advance for any thoughts.
Logged
dihardja
Jr. Member
**
Posts: 17


View Profile Email
« Reply #1 on: September 17, 2009, 02:09:57 »

probably by handling this in a proxy ( e.g. CoordinatesProxy ) which calls the service as much as needed until all coordinates data is available, then notify the system that the proxy is ready to be used.

this way, the orders of the requests is handled inside the proxy. the rest of the system then only needs to get the coordinates value from the method interfaces of the proxy.
« Last Edit: September 17, 2009, 02:13:14 by dihardja » Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #2 on: September 17, 2009, 07:22:42 »

Maybe Loadup utility could help.  In this case, rather than a set of different ILoadup proxy classes, sounds like you would have one class and you would create a separate instance for each coordinates.
----Philip
Logged
99miles
Jr. Member
**
Posts: 14


View Profile WWW Email
« Reply #3 on: September 17, 2009, 11:25:30 »

Thanks guys.
Okay, I'm trying to use Loadup Util.

Once I get the path, I call LoadElevationCommand with a 'directions' object.

Because I need to put the results in order after they are retrieved, I have created a Proxy that does nothing but hold an array of 'points' created by the LoadElevationCommand from the 'directions' object.

Then when each call comes back to the mediator I check the 'point', find that 'point' in the array stored by the proxy, and set the elevation property. Then on Loadup.LOADING_COMPLETE I can do what I wish with all the results.

Does that makes sense, or am I over-complicating it?
« Last Edit: September 17, 2009, 01:25:54 by 99miles » Logged
sasuke
Full Member
***
Posts: 29


View Profile Email
« Reply #4 on: October 15, 2009, 09:00:33 »


I'm looking for the best (or at least a good) way to handle the following:

I need to call one HTTPService many times, and wait for all the results, and put them in order.

The reason is, I have a path of coordinates, and for each I call a service to get the elevation of that point. Once I have them all I will chart them, so they need to be in order of the path.

Thanks in advance for any thoughts.
IMO, calling a remote method for each and every *point* is way too expensive. I don't know the scale of your application but with multiple users, this might just bring the system to its knees. You might want to try imparting batch processing capabilities to your HttpService and make it accept a list of points which in turn would return a list of elevations. Just a thought...

BTW, how are you associating each unique response received with the request which initiated it? Asynctoken?

-sasuke
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #5 on: October 17, 2009, 02:52:27 »

You might want to check out the LoadUp utility and the LoadUpAsOrdered Demo

-=Cliff
Logged
Pages: [1]
Print