Re: [Cppcms-users] Consumer producer problem
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2013-03-13 10:57:40
|
>
> [...]
> In the end it looks like I have a one process <----> one browser session
> connection.
>
> [...]
> --
> Christian Gmeiner, MSc
So why not just use?
// disable gzip to allow transparent flush
response().io_mode(nogzip);
// something like that not remember exactly the content type and API
response().content_type("text/event-stream");
while(get_some_input_from_process()!=EOF) {
sse::write_event(response().out(),id,data);
response().out() << std::flush;
}
Of course there is no way to reconnect and see what happens if you closed
the session...
Artyom Beilis
--------------
CppCMS - C++ Web Framework: http://cppcms.com/
CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/
>>
>> However if you have many clients and one source it is
>> a different problem.
>>
>> What happens if somebody requests the date after the process
>> started do you send it from the begging or from the last
>> event? What happens on reconnect you need to start from the
>> last point but how long do you want to keep the data?
>>
>> In general you can keep all events - all the output
>>
>> and send it from the beginning, in such case you can either
>> make the ring buffer with a big ring or just alter
>> the class
>>
>>
> http://sourceforge.net/p/cppcms/code/2238/tree/framework/trunk/contrib/server_side/sse/server_sent_events.h
>>
>>
>> With the policy you need. You can derive the event_source
>> class and provide the policy of keeping and throwing messages
>> the way you need.
>>
>
> As far as I have seen the broadcast() method in the event_source class
> works asynchronously. So I need
> to change it to be synchronously.
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
|