Jump to content

Ajax App Design, Long Polling.


AbydosGater

Recommended Posts

Hi, I guess this post is more Application Design, but the question itself regards to AJAX Design Techniques so I posted it here.

 

I am in the initial planning stages for a community based website that I plan on developing with GWT and a PHP Backend.

I was wondering if anyone could offer some architectural advice?

 

The application will have several activities that the user can switch between, such as forums/topics or viewing/posting blogs.. ect.

There will also be static modules on the page that will require to listen for updates from the server. Such as a shoutbox and a users online list.

 

I am leaning towards using long polling, seems like a good idea. Send a request to a PHP script and POST a list of activities the user is doing such as viewing a forum, and then when something on that forum updates the PHP can return with the update.

 

The only problem with this is what if the user changes activities after the request is made. I.E: Client sends a request to be updated about a certain forum, but then starts browsing another.

 

I can come up with two ways around this..

 

1) When the user changes activity.. kill the request and start a new one.

 

2) Have two requests. One long polling request waiting for updates, not sending what the user is doing. When the user changes activity, a second request to another PHP script updates the users SESSION to what they are doing, then when the long polling request gets the update in session it checks for those updates instead.

 

Both have their advantages and disadvantages. The first one only ties up one of the 2 connection limit imposed by most browsers, but had a lot of extra network overhead with killing/resending requests. The second one involves using up both of the 2 connections from time to time. Although the second connection would not last, just update the session info.

 

Has anyone encountered such a design problem? Could someone offer someadvice on how I should tackle this?

 

Thanks for your time in reading.

Andy

 

(Update, just stumbled upon some more information, the 2 connection limit defined in the RFC 2068 has pretty much been ignored by some browsers such as IE and FF. So shouldnt be an issue)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.