dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Multiple URLLoader.load() calls

  1. #1
    Señor Member Mavrisa's Avatar
    Join Date
    Oct 2005
    Location
    Canada
    Posts
    506

    Multiple URLLoader.load() calls

    Hi,
    Yesterday I posted an online game that I just finished* and had some of my friends test it out with me. There are a number of things that went wrong. I'm wondering though... I have a timer with an interval of 2 seconds calling on a URLLoader instance to grab data from a database. So I have 2 questions:

    1) Is it possible that the server's response + the load time might be longer than 2 seconds?
    2) Is it going to be a problem for flash if I call load() again before the first load() operation finishes? What would be the result of that? Does it do both, or cancel the first one, or what? Because I noticed even just sitting there, I get an error every 3-5 minutes or so. I get an HTTPStatusEvent followed by an IOErrorEvent when this happens.

    Thanks for any advice you can give me,
    Mavrisa

    *Well I say finished.. but I still have to iron out the kinks.
    Haikus are easy
    But sometimes they don't make sense
    Refrigerator

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    1) Yes.
    2) I don't see documentation on what happens if a second load is called before the first completes. In a plain Loader, the first one is discarded. Regardless, the server will still try to send the data from the previous loads until it's finished.

    Have you considered using an XMLSocket instead of multiple loads of a URLLoader?

  3. #3
    Señor Member Mavrisa's Avatar
    Join Date
    Oct 2005
    Location
    Canada
    Posts
    506
    Ehhh... no? Is that better?
    Haikus are easy
    But sometimes they don't make sense
    Refrigerator

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    A Socket or XMLSocket connection would be a single connection through which you can "push" updates from the server rather than poll for them on the client. This would eliminate the possibility of overlapping update requests, as well as be more efficient on bandwidth for both client and server.

    The downside is that you would have to rewrite your server-side code to allow this. Depending on what you're using server-side, there may be packages which handle the heavy lifting for you, but this is not a trivial change. You have to re-write the client side code too, but that's a smaller change.

  5. #5
    Señor Member Mavrisa's Avatar
    Join Date
    Oct 2005
    Location
    Canada
    Posts
    506
    Well as usual, the documentation isn't helpful. Any tutorials to get me started? My google searches are coming up empty.. Also, is there some [easy] way to tell if my host would support xmlSocket connections, or do I just have to ask?
    Haikus are easy
    But sometimes they don't make sense
    Refrigerator

  6. #6
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    What server-side technology are you using?

    For python there's palabre

    For java, there's dozens of simple examples (like http://giantflyingsaucer.com/blog/?p=205 ), but I did not find a polished package in my cursory search.

    For php, there are also a few simple examples ( http://www.kirupa.com/forum/showthread.php?t=289816 ), but I did not find a polished package.

    There's also http://playerio.com/ for a polished framework (using their hosting) and
    adobe's stratus

  7. #7
    Señor Member Mavrisa's Avatar
    Join Date
    Oct 2005
    Location
    Canada
    Posts
    506
    I've been using php, although it was really my first attempt to understand it, so I don't really have much familiarity with it. As such, the server made by Alex Petrescu really confuses me. Palabre would be great it seems, but the host I'm using doesn't support python.

    Edit: Alrighty, a few questions:
    1) This method saves nothing on the server, correct?
    2) If 1 is true, then how would I go about setting up "rooms"? I plan to have several games (each one was a row in a database).
    Probably more to come...

    Thanks for your help so far 5Tons.
    Last edited by Mavrisa; 07-05-2010 at 05:45 PM.
    Haikus are easy
    But sometimes they don't make sense
    Refrigerator

  8. #8
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    1) It uses a persistent connection rather than several transactions, so you do avoid the overhead associated with establishing an http connection several times. That may actually be significant. The actual effect will depend on several factors, including how many connections it saves, the number of concurrent players, and how much state is maintained on the server.

    2) In addition to stratus, adobe used to have a beta thing called cocomo. But they've apparently turned that into some livecycle collaboration service, which is of course not free.

    Player.io also provides lobby and room stuff, and they have a free account level. I'm not sure whether the free level is appropriate for multiplayer. Server-side code must be done in a .net language.

    If you're rolling your own solution, lobbies and rooms are just a matter of designing your db and interface correctly. Not to say it's trivial, but it's not exactly breaking new ground either.

  9. #9
    Señor Member Mavrisa's Avatar
    Join Date
    Oct 2005
    Location
    Canada
    Posts
    506
    I think I'll try an XMLSocket another time... it seems I've found a way to get around most of the problems I've been having. It turns out two of the biggest problems arose because I was being sloppy with removing my event listeners. Missed a few places... *dumb*
    Haikus are easy
    But sometimes they don't make sense
    Refrigerator

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center