I read the specification and few examples/tutorials about Server Side Events, but I do now fully understand the entire process.
If when using ajax the request->response cycle is simple to understand, here it seems to be a little bit complicated. As described here : http://dsheiko.com/weblog/html5-and-server-sent-events, I do not understand who/what generates the events on server. It’s like someone keeps calling the server script and this is generating the random numbers.
More than that, the author says:
"Moreover, you don’t need to apply a loop-cycle in the event source script. That will seem as repeat of pushing messages to the client automatically."
How is this happening?
As far as I can see a server side PHP script sends a message periodically. In the example the link to the script is in a tag called
event-sourceand the script seems to beevents.php. The messages send are handled by the functiononMessageHandler. The handler is assigned to the<event-source>-tag itself, for Opera aserver-timeevent is handled, for Webkit amessageevent. It’s the (HTML5 enabled) browser that takes care of the polling, so in fact it looks most like a browser implementation of long polling.Concerning your question i do not understand who/what generates the events on server: there are no events generated server side, it’s just a PHP-script called periodically. In the example that script returns a time stamp.