You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
generationtech
changed the title
Calls to web::websockets::client::websocket_client::receive always returns even if there is no data
Calls to websocket_client::receive always returns even if there is no data
Oct 8, 2016
generationtech
changed the title
Calls to websocket_client::receive always returns even if there is no data
Calls to websocket_client::receive always return even if there is no incoming message
Oct 8, 2016
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.
The text was updated successfully, but these errors were encountered: