Loading ...
Sorry, an error occurred while loading the content.

371Re: Connection Manager - Multiple Posts - Catching Open Connections

Expand Messages
  • David Prusak
    Mar 2, 2006
      --- In ydn-javascript@yahoogroups.com, "Thomas S. Sha" <tsha@...>
      > --- In ydn-javascript@yahoogroups.com, "David Prusak" <dprusak@>
      > > The sudo code I have now is:
      > >
      > > for (each hard drive){
      > > if there is a saved list
      > > var mySave = YAHOO.util.Connect.asyncRequest
      > > ('POST',uiServer+'/save.php, callbackSave, savedListPostData);
      > > if there is a delete list
      > > var myDelete = YAHOO.util.Connect.asyncRequest
      > > ('POST',uiServer+'/delete.php, callbackdelete,
      > > }
      > >
      > > This can create multiple connection handle and what I'm, not
      fond of
      > > is the possibility of the variable getting stomp over if there
      > > more than 1 hard drive.
      > If I understand your request correctly, you can do this:
      > var mySave = [];
      > var myDelete = [];
      > for (var i=0; i<=numberOfDrives; i++){
      > if(savedList){
      > mySave[i] = YAHOO.util.Connect.asyncRequest(savedListArgs);
      > }
      > else if(deleteList){
      > myDelete[i] = YAHOO.util.Connect.asyncRequest(deleteListArgs);
      > }
      > }
      > If there are multiple connection requests, whether a mix of mySave
      > and, or myDelete, you will have a unique reference to the request,
      > the event you should ever have to abort it or check its progress.
      > Moreover, the createXhrObject method is essentially an object
      > that returns a new XHR for each request.
      > Hope this helps.
      > Regards,
      > Thomas

      Hi Thomas,

      That's what I progressed to. I have an array of objects now. Each
      connection has something like:



      The problem I'm having now, is that I have multiple connections
      created and they all call the success/fail callback function. The
      trouble I'm having is catching or logically knowing that all
      connections have finished one way or the other.

      What I've done to get around that is to count the number of elements
      in the array (length) and with a global variable, count the number
      of times the success or failure callback is called. It works, but
      it's really messy.

      What I was asking for is that if one would have to make multiple
      async connections, if it could be bundled one 1 connection (possibly
      creating an object of connections and passing it to the connection
      manager). When all have completed, return the object with a
      success/fail for each. It would be cleaner to process a single
      return than multiple returns. (of course, I'm missing a strong point
      here :) )

    • Show all 3 messages in this topic