Re: [Cppcms-users] How to combine SSE with the url dispatcher
Brought to you by:
artyom-beilis
|
From: Marcel H. <ke...@co...> - 2014-02-22 13:11:40
|
Hi Eric,
I have the feeling that you don't read my mails... I apologize, that I'm
not a native speaker but I think, that you can understand what I write.
I'd like to mention it once again.
***A stream is not something that you view in your browser!***
It's not a webpage, it's a stream of information that can be access and
evaluated by a javascript/cpp/perl/python/... programm.
There are two major problems in your approach.
1. You view the stream in your browser. That's not how it works. Please
adapt your 'showstatus.html' in line 14 to this:
> var stream = new EventSource('/robot/showstatus');
and replace the showStatus method with this
> void MyApp::showStatus()
> {
> stream_->accept(release_context());
> }
Then you can access it via:
> http://localhost:8080/showstatus.html
and see the promised result. I also attached the 'corrected' version.
I think, that your problem is, that you want both - stream and page - in
on method, but that won't work. You must have a synchronous app that
will deliver the page content [0] and a asynchronous app that will
deliver the data via sse.
The static content will be delivered via the internal file server of
cppcms in this way, but you should not rely on that in a productive
environment [1].
So. You need one application for the sse part and another application
for the webpage part.
The second major problem in your current version is, that you cannot
open that (wrong) page twice. Try to open another tab and view that page
again. It won't work. The can and should read the reason why [2][3].
So I hope that you won't be angry. Read the given pages and then I hope
you can answer your questions that you have. Of course, feel free to ask
more questions.
Greetings,
Marcel
[0] http://cppcms.com/wikipp/en/page/cppcms_1x_tut_hello
[1] http://cppcms.com/wikipp/en/page/cppcms_1x_serving_static_files
[2] http://cppcms.com/wikipp/en/page/cppcms_1x_application_lifetime
[3] http://cppcms.com/wikipp/en/page/cppcms_1x_event_loop
|