I'm currently trying to read data from websocket which takes user input. At the same time, I also write data to the websocket. It used to work when I only write data to the websocket. However, the program seems to halt when I try to read and write to websocket. The following is the code that I've tried.
if(!messageQ.empty())
{
//if (recvbuf.ch_idx == 1)
//cout << "Ws Write " << gs32cnt1 << endl;
boost::beast::flat_buffer buffer;
ws_.write(net::buffer(*messageQ.front()));
ws_.read(buffer);
cout << "ws Read " << endl;
auto out = boost::beast::buffers_to_string(buffer.cdata());
string stringVal;
stringVal = out;
std::cout<<"stringVal = "<<stringVal<<std::endl;
//printf("BAAAM! %d\n", m_count_objects);
messageQ.pop_back();
As you can see it, I call 'read' method right after 'write' method. This doesn't seem right anymore. Can any wise websocket guru lend me a helping hand? Thanks in advance!