Reputation: 15925
Do all comet style applications require a loop somewhere in the application on the serverside to detect updates/changes? If no, please could you explain how the logic behind a loopless comet style application would work?
Upvotes: 1
Views: 297
Reputation: 716
The solution could be stream_set_blocking. Use any possible blocking resource to be suspended by OS and wait for appropriate interruption.
Client side:
Server setup:
Script one:
Worst thing is that you need to think how to get multiple reader scripts reading from same bus (file) without disturbing each other. Also there could be that timeout will be exactly at that time when message will be written into bus.
(hope that this solution is not as bad as my English)
Upvotes: 1
Reputation: 2720
Short answer is, no, not all require a loop on the serverside.
Instead you can use long-polling AJAX calls from the browser to request data,
at which the server simply responds with the data and the browser waits until the response is gotten before sending a new request.
Upvotes: 1
Reputation: 46756
This kind of application will always require a loop, you need to periodically check for new data etc. Of course you can make the "loop" non-blocking by using an even-loop based approach, but in the end there's still a loop somewhere.
Just think about it for a moment, how would you make it work without a loop? I sure can't imagine a way that doesn't utilize a loop somewhere.
Upvotes: 1