mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-27 18:47:55 +00:00
MtService: using default expert if handle is zero
This commit is contained in:
+16
-1
@@ -259,7 +259,22 @@ void MtServer::ProcessMessage(const std::string& msg, std::weak_ptr<MtConnection
|
||||
if (command)
|
||||
{
|
||||
auto expert_handle = command->getExpertHandle();
|
||||
if (experts_.count(expert_handle) > 0)
|
||||
if (experts_.size() == 0)
|
||||
{
|
||||
log_.Error("%s: Expert list is empty. There is no any command executor.", __FUNCTION__);
|
||||
}
|
||||
else if (expert_handle == 0)
|
||||
{
|
||||
// use default expert
|
||||
auto expert = experts_.begin();
|
||||
log_.Debug("%s: using default expert for executing command - %d" , __FUNCTION__, expert->first);
|
||||
expert->second->expert->Process(std::move(command), [con = con, this](const MtResponse& response) {
|
||||
auto connection = con.lock();
|
||||
if (connection)
|
||||
connection->Send(response.Serialize());
|
||||
});
|
||||
}
|
||||
else if (experts_.count(expert_handle) > 0)
|
||||
{
|
||||
experts_[expert_handle]->expert->Process(std::move(command), [con = con, this](const MtResponse& response) {
|
||||
auto connection = con.lock();
|
||||
|
||||
Reference in New Issue
Block a user