Server-Sent Events in CppCMS Trunk
8/28/12, by artyom ;
Posted in:
Comet;
one comment
There is a simple class added to the contrib section in trunk.
https://cppcms.svn.sourceforge.net/svnroot/cppcms/framework/trunk/contrib/server_side/sse/
The Server-Sent Events support is provide in form of a generic class sse::event_source
that the user expected to derive from.
Also two simple event source objects with a predefined policy:
- Queue bounded up to certain capacity:
sse::bounded_event_queue
- Real time state updates that allows to keep clients updated with the latest events - rather than sending all the events from the beginning:
sse::state_stream
Examples of a simple chat and a stock ticker are provided.
Notes:
- the
sse::event_source
supports falling back to long polling using XHR by sending a special header, notifying the server that the connection should be closed rather than kept open. - Also the code resides withing trunk, it is fully useful with current stable CppCMS release - 1.0.2.
- This code does nothing exceptional, you don't really have to use it to create SSE, it is just makes it easy to handle them without knowing too much about server-side event driven programming.
Comments
Mmm... Loved :) Artyom thank you.
Add Comment:
You must enable JavaScript in order to post comments.