Description
I bet there's an easy explanation for this or suggested implementation. I have (what I think) is a working websocket setup between cpprestsdk and django channel application across the network. I can send and receive test websocket messages between them.
On the cpprestsdk part, when I make calls to websocket_client::receive, it always returns even if there's no incoming message. How should I structure a program to block waiting for a new message or is there some other better way to handle this.
For now, I'm just using the sample code and calling it from a simple loop to verify this behavior.
void cl_WebsockManager::receive(void) { wsm_client.receive().then([](websocket_incoming_message msg) { return msg.extract_string(); }).then([](std::string body) { std::cout << body << std::endl; }); }
for (int i = 1; i < 100; i++) { std::cout << i << std::endl; wsm_game->receive(); }
I can't seem to find any detailed useful examples for the cpprestsdk implementation of websockets and the one community example referenced on the wiki seems really complicated for my purpose and if I understand that code, just runs basically a continuous recursive loop calling the .receive()
https://blogs.msdn.microsoft.com/vcblog/2014/06/25/c-rest-sdk-websocket-client/
Thanks for any help.