Process messages asynchronously

This commit is contained in:
badaix 2021-06-10 08:55:31 +02:00
parent 5e2d14d39a
commit 0eaee48f10
10 changed files with 106 additions and 89 deletions

View file

@ -61,9 +61,10 @@ void ControlSessionTcp::do_read()
// LOG(DEBUG, LOG_TAG) << "received: " << line << "\n";
if ((message_receiver_ != nullptr) && !line.empty())
{
string response = message_receiver_->onMessageReceived(this, line);
if (!response.empty())
sendAsync(response);
message_receiver_->onMessageReceived(shared_from_this(), line, [this](const std::string& response) {
if (!response.empty())
sendAsync(response);
});
}
}
streambuf_.consume(bytes_transferred);