|
-
Nov 3rd, 2011, 04:11 AM
#1
[RESOLVED] [jQuery & PHP] Long polling or Comet programming in Chat ?
Hi guys 
I have developed a chat application using PHP and jQuery. So, at the moment, my chat app would poll the server every 2.5 seconds, with the last message's id as GET request. And in the server side, the script will establish a db connection and check whether any new messages are arrived which is greater than the message_id that was received through GET request.
If found, echo the new messages. Otherwise, echo empty string. So far it works okay.
But I have heard that we could make the polling efficient by using a long polling method or a comet programming method. Based on the my research(search done on Google ), I found that comet is not cross-browser supporting. So, I thought about the long polling mechanism. But what it does is, it would use a loop in the serverside, checking for new data arrivals and if so, echo it. Otherwise, stay in the loop until new messages comes.
But wouldn't it eat server resource ?
Do you think long polling would be the best ? Or do you know some other technique which is more efficient ?
Thanks
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|