server side events (for dummies:) )

Go To


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 : ,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?


2012-04-04 05:28
by Videanu Adrian


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-source and the script seems to be events.php. The messages send are handled by the function onMessageHandler. The handler is assigned to the <event-source>-tag itself, for Opera a server-time event is handled, for Webkit a message event. 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.

2012-04-04 05:57
by KooiInc
ok, i understand. Thanks - Videanu Adrian 2012-04-04 11:13