Server Sent Events on cpprest

Nov 5, 2015 at 9:21 AM
Edited Nov 5, 2015 at 9:24 AM

I need to implement a Server Sent Event interface for a watchdog I am developing, the problem is that I cant find a way to do multiple reply() functions on one web::http::http_request object. So what I'm trying to do is more or less the following:
    void wwwReports(web::http::http_request request){
        watchdog::hdmiWatchdog &watcher = watchdog::hdmiWatchdog::getInstance();
                while(//check if client is connected){
                            //wait for a new report
                            watchdog::report reportToSend = watcher.getNewReport(); 
                            web::json::value report = report2Json(reportToSend);

But I only get the first report, do anyone know if there's a way to implement this?
I suppose it might be related to request.set_response_stream() but I couldn't find a way to make it work.

Nov 5, 2015 at 6:50 PM
Hi fcaldas,

I don't think we currently support Server Sent Events with our http_listener. As you've noticed, its APIs assume a standard single-request/single-response flow.

Depending on how simple your application is, you may be able to directly use TCP to accomplish what you need.

Nov 6, 2015 at 10:03 AM
Thanks roschuma,

I ended up using boost to run a small SSE server on another port in parallel.