my own long polling implementation compared to facebook and gmail
Asked Answered
E

2

6

For days I have been experimenting with long polling/comet implementation for my site. I got the basic idea of how it works, this is where i run some tests.

On the other hand, I have been observing(firebug) how gmail and facebook implement long polling. What I noticed with gmail is that the ajax request does not continuously follow right after the current request expires, but it waits for several seconds/minutes before it fires the next one.

I played with it some more. I tried to login with gmail account A in firefox and gmail account B in chrome. I waited when the current ajax poll finishes and then I sent an email from account B to A. I was expecting that account A won't receive it until the next poll, but to my surprise Account A directly received it right after I hit the submit button.

How does gmail do this with long polling ?

If you try to visit my site and click on the Run button and open firebug, you can see that ajax spinner is always running. when the server responds with data, it requests the server again.

Exactitude answered 26/9, 2011 at 4:13 Comment(0)
P
1

I think your assumption that Gmail uses (only) long polling is incorrect. According to this question (and the answer) it uses forever frame, and forever XHR. See also BrowserChannel, which they use for Gmail Chat.

Peta answered 26/9, 2011 at 4:24 Comment(1)
You might also be interested in socket.io's codeDwaynedweck
R
1

Take a look at WebSync from Frozenmountain or SignalIR which take the work out of the backed pieces. I can vouch for websync as I use it everyday, but been hearing good things about signalir.

Reprieve answered 26/9, 2011 at 4:19 Comment(1)
i have downloaded the free version. but i prolly have to learn more about the basics first, thanks tho :)Exactitude
P
1

I think your assumption that Gmail uses (only) long polling is incorrect. According to this question (and the answer) it uses forever frame, and forever XHR. See also BrowserChannel, which they use for Gmail Chat.

Peta answered 26/9, 2011 at 4:24 Comment(1)
You might also be interested in socket.io's codeDwaynedweck

© 2022 - 2024 — McMap. All rights reserved.