Jbudone Posted September 11, 2011 Share Posted September 11, 2011 As of now, I am so very lost! I have recently discovered this awesome technique called Comet, aka Reverse AJAX aka HTTP Push.. The idea is simple: With a "Forever iframe" you can load up a script from the server which constantly loads, and flush()'s buffered output to the client in the form of Javascript script's. These scripts may then be executed on the client WHILE the php script is still executing, hence allowing the serverside script to push events to the client as they come up. Another trick is using AJAX Longpolling, which is simply creating an AJAX request, and on the serverside if there's no events or valid data to return to the client, then it simply performs a quick sleep() and looks again for new data/events to return. As soon as it returns any data, another AJAX request is made and sent back to the server. My problem is that I'm trying to send AJAX requests WHILE one of my Comet connections is alive. I've tried it both with the forever iframe, and with AJAX's longpolling. But the issue is that my AJAX requests seem to be put on a queue, and aren't sent to the serverside until AFTER the connection closes from the iframe, or until my other AJAX LongPolling request finally returns. This is bad for me, because my goal is to create a Comet-based chatroom server; where the Comet side of things will continuously look for new messages in the chatroom and push it to the client, while concurrent AJAX requests can be sent to the server (eg. user types a message, leaves the channel, joins another channel, etc.) I've looked all over Google, asked around on IRC, and tried all sorts of test. But I can't find a single person with the same problem as me, and I can't figure out how to get this to work or what the problem could possibly be. Is this normal behavior? Are AJAX requests not supposed to be able to send until after an iframe connection has been closed, and previous AJAX requests return first? Or maybe its because both my longpolling ajax requests call the same server script? Is there any way I can get around this? Anything anything I can do? Any tips, suggestions or enlightment in the area would be very much appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/246925-cometlongpolling-with-concurrent-ajax-calls/ Share on other sites More sharing options...
sunfighter Posted September 12, 2011 Share Posted September 12, 2011 A coup;e of days ago someone suggested a program (formally called chat) now called APE http://www.ape-project.org/ that does what you want; I beleive. It's worth a look see. It has a wiki and a forum. Quote Link to comment https://forums.phpfreaks.com/topic/246925-cometlongpolling-with-concurrent-ajax-calls/#findComment-1268191 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.