mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 10:24:26 +01:00
Added response to subscription
This commit is contained in:
parent
b07c0e8f54
commit
80d8610559
@ -105,20 +105,20 @@ static void session(tcp::socket &&sock)
|
||||
l(response.message, LogLevel::warning);
|
||||
goto out;
|
||||
}
|
||||
|
||||
response.code = Response::Code::Success;
|
||||
response .message = "";
|
||||
sock.write_some(boost::asio::buffer(response.toJson()),
|
||||
error);
|
||||
|
||||
while (run) {
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
onClientMessage.wait(lock);
|
||||
|
||||
if (sock.is_open() == false) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (run) {
|
||||
sock.write_some(boost::asio::buffer(logic->getClientMessage().toJson()));
|
||||
}
|
||||
};
|
||||
|
||||
response.code = Response::Code::Success;
|
||||
} else {
|
||||
response.code = Response::Code::UnknownCommand;
|
||||
response.message = "Received unknown command " + command;
|
||||
@ -126,7 +126,6 @@ static void session(tcp::socket &&sock)
|
||||
}
|
||||
|
||||
out:
|
||||
if (sock.is_open()) {
|
||||
sock.write_some(boost::asio::buffer(response.toJson()),
|
||||
error);
|
||||
if (error == boost::asio::error::eof)
|
||||
@ -134,7 +133,6 @@ static void session(tcp::socket &&sock)
|
||||
else if (error)
|
||||
throw boost::system::system_error(error);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e) {
|
||||
std::string message = "Exception in session " + remoteAddress.to_string()
|
||||
+ ":" + std::to_string(remotePort) + " : " + e.what();
|
||||
|
Loading…
Reference in New Issue
Block a user