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

Re: Connection Manager - Multiple Posts - Catching Open Connections

Expand Messages
  • Thomas S. Sha
    ... If I understand your request correctly, you can do this: var mySave = []; var myDelete = []; for (var i=0; i
    Message 1 of 3 , Mar 1, 2006
    • 0 Attachment
      --- In ydn-javascript@yahoogroups.com, "David Prusak" <dprusak@...> wrote:

      > 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, deleteListPostData);
      > }
      >
      > This can create multiple connection handle and what I'm, not fond of
      > is the possibility of the variable getting stomp over if there are
      > 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, in
      the event you should ever have to abort it or check its progress.
      Moreover, the createXhrObject method is essentially an object factory
      that returns a new XHR for each request.

      Hope this helps.

      Regards,
      Thomas
    • David Prusak
      ... deleteListPostData); ... fond of ... are ... in ... factory ... Hi Thomas, That s what I progressed to. I have an array of objects now. Each connection
      Message 2 of 3 , Mar 2, 2006
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "Thomas S. Sha" <tsha@...>
        wrote:
        >
        > --- In ydn-javascript@yahoogroups.com, "David Prusak" <dprusak@>
        wrote:
        >
        > > 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,
        deleteListPostData);
        > > }
        > >
        > > This can create multiple connection handle and what I'm, not
        fond of
        > > is the possibility of the variable getting stomp over if there
        are
        > > 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,
        in
        > the event you should ever have to abort it or check its progress.
        > Moreover, the createXhrObject method is essentially an object
        factory
        > 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:

        mySaveArray[0]
        .connection
        .postData
        .otherData

        etc..

        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 :) )

        Thanks!
        --David
      Your message has been successfully submitted and would be delivered to recipients shortly.