views:

311

answers:

3

what they do on this demo is exactly what i wanna do.

http://www.lightstreamer.com/demo/RoundTripDemo/

i wonder what comet technique they are using.

it cant be iframe cause on Firefox i can open two tabs with same link. with iframe u cant do that. and it cant be long polling with ajax cause i didnt see it polled anything with firebug.

someone knows the answer? (would be great with some link to good tutorials that do exactly the same thing with same technique).

+1  A: 

Whilst digging through the obfuscated scripts is not something I fancy right now, judging by the contents of the page DOM it is posting data from a <form> inside a hidden <iframe> to send data to the server, and having the server send back <script> tags with code to pass data back to the caller.

This is a rather heavyweight and obtrusive technique. It was the only way of doing in-page server communication in the days before XMLHttpRequest existed; I typically wouldn't use it today.

(I wish WebSocket would hurry up and get implemented, doing away with all the long-polling nastiness.)

bobince
so it is using iframe streaming technique? but isnt that one of the reliable techniques nowadays for comet?
weng
Yes. Certainly, as you can see, it works... albeit with unsightly side-effects like pegging the browser ‘loading...’ state. I'm not sure what the problem you are referring to with opening two tabs on the same link is.
bobince
With iframe you cannot have two pages opened up in Firefox at the same time cause it just allows one iFrame at the time. Cause it thinks the first iframe (which is reloading forever) hasnt finnished reloading thus waiting for it to finnish first before it refreshes the other page. i have tried this and its how it works. but with lightstreamers roundup demo it works with multiple pages of that demo opened. but arent they using iframe? Test http://www.zeitoun.net/articles/comet_and_php/start . Just download the iframe method and try to have 2 tabs opened in Firefox. the second one wont work.
weng
You're talking about the 2-connections-per host limit? This is gradually being lifted, but it's easy to work around by using multiple hostnames, eg. `session-4832.example.com` and using wildcard DNS to resolve them all to the server. The lightstream demo seems to be using a different method where only one iframe talks to the server, and forwards messages to the other documents open in the same browser.
bobince
+1  A: 

Looks like several techniques developed by Lightstream which include "vanilla" comet. A brief excerpt from the Lightstreamer white paper:

Each Lightstreamer client typically opens a single permanent connection with Lightstreamer Server, on which the push updates relating to an arbitrary number of items, frames and windows travel by means of multiplexing techniques.

The white paper and demos are very interesting...

Upper Stage
+1  A: 

Once I developed a module for the Lighttpd web server. The module implemented a Full Duplex Ajax technique, very similar to Comet. In my blog posts you'll find everything you need about FDAjax / Comet, JavaScript examples, problems with firewalls and anti-virus programs, etc.

Lighttpd project seems to be dead. As far I know there is a similar module for the popular nginx. However in future we'll use web sockets.

BTW I used few HTTP addresses (www1.example.com, www2.example.com, ...) to work around the browsers limit of max two IP concurrent connections to the same web server. www[n] were in fact resolved to the same IP address. In case of possible lockup, a browser was automatically redirected to the next www[n] address.

Greg Dan
ok good work around. i will try that one to resolve the max-2-ip issue.
weng