server: clarifying things

This commit is contained in:
Stéphane L 2019-01-01 15:57:29 +01:00
parent 40e2d410dd
commit baac1b1d80

View File

@ -132,18 +132,22 @@ void WSServer::onMessage(connection_hdl hdl, server::message_ptr message)
return;
}
std::string payload = message->get_payload();
QMutexLocker locker(&_clMutex);
QVariantHash connProperties = _connectionProperties[hdl];
locker.unlock();
std::string payload = message->get_payload();
WSRequestHandler handler(connProperties);
std::string response = handler.processIncomingMessage(payload);
_server.send(hdl, response, websocketpp::frame::opcode::text);
locker.relock();
// In multithreaded processing this would be problematic to put back
// a copy of the connection properties, because there might conflicts
// between several simultaneous handlers.
// In our case, it's fine because all messages are processed in one thread.
_connectionProperties[hdl] = connProperties;
locker.unlock();
}