dhbaird / easywsclient

A short and sweet WebSocket client for C++
MIT License
741 stars 205 forks source link

receive from server without busy wait #47

Closed jageee closed 8 years ago

jageee commented 8 years ago

From the "example-client.cpp" i see that in order to handle received data from server i need busy wait:

while (ws->getReadyState() != WebSocket::CLOSED) {
  ws->poll();
  ws->dispatch(handle_message);
}

Is there some interrupt/callback mechanism to handle rx instead?

Thanks.

dhbaird commented 8 years ago

Unfortunately, this is a known limitation of the current API. There is a workaround: dedicate a thread to websocket handling, and that thread interrupt can some other thread. Hope that helps. Feel free to re-open this issue if more discussion is needed.