Hi all
I try to get server sent events using ofxHTTP.
The server sends events like:
event: userlogon\n
data: {“username”: “John123”}\n\n
I do it like in the basic client example:
std::string url = "http://localhost:8080/events";
ofx::HTTP::DefaultClient client;
ofx::HTTP::Context context;
ofx::HTTP::BaseResponse response;
ofx::HTTP::GetRequest request(url, Poco::Net::HTTPMessage::HTTP_1_1);
// Execute the request and get the response stream.
std::istream& responseStream = client.execute(request,
response,
context);
// Request and response headers can be examined here.
// Copy the output to the terminal.
Poco::StreamCopier::copyStream(responseStream, std::cout);
// Flush the input stream.
std::cout << std::endl;
That gives me some updates in the console but not in realtime and not the full messages.
I also tried it like in the example_basic_client_loader
there i get progress notifications, but i don’t understand how to get the data there.
All i basically want is listen to http://localhost:8080/events and get a notification and the data when a \n\n is coming in.
I also tried it with ofLoadURL() but there i just get a spinning beachball. I guess, i should use some sort of non blocking technique but i don’t understand how to do that.
can someone put me in the right direction here? thanks!