webthrottle: moved common release code to function
Dieser Commit ist enthalten in:
Ursprung
bdcb5574f8
Commit
fcbec85ee8
@ -237,14 +237,7 @@ void WebThrottleConnection::processMessage(const nlohmann::json& message)
|
|||||||
else if(action == "release")
|
else if(action == "release")
|
||||||
{
|
{
|
||||||
throttle->release(message.value("stop", true));
|
throttle->release(message.value("stop", true));
|
||||||
|
released(throttleId);
|
||||||
m_trainPropertyChanged.erase(throttleId);
|
|
||||||
|
|
||||||
auto response = nlohmann::json::object();
|
|
||||||
response.emplace("event", "train");
|
|
||||||
response.emplace("throttle_id", throttleId);
|
|
||||||
response.emplace("train", nullptr);
|
|
||||||
sendMessage(response);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,11 +278,7 @@ const std::shared_ptr<WebThrottle>& WebThrottleConnection::getThrottle(uint32_t
|
|||||||
m_throttleReleased.emplace(throttleId, it->second->released.connect(
|
m_throttleReleased.emplace(throttleId, it->second->released.connect(
|
||||||
[this, throttleId]()
|
[this, throttleId]()
|
||||||
{
|
{
|
||||||
auto response = nlohmann::json::object();
|
released(throttleId);
|
||||||
response.emplace("event", "train");
|
|
||||||
response.emplace("throttle_id", throttleId);
|
|
||||||
response.emplace("train", nullptr);
|
|
||||||
sendMessage(response);
|
|
||||||
}));
|
}));
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
@ -297,3 +286,14 @@ const std::shared_ptr<WebThrottle>& WebThrottleConnection::getThrottle(uint32_t
|
|||||||
|
|
||||||
return noThrottle;
|
return noThrottle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebThrottleConnection::released(uint32_t throttleId)
|
||||||
|
{
|
||||||
|
m_trainPropertyChanged.erase(throttleId);
|
||||||
|
|
||||||
|
auto response = nlohmann::json::object();
|
||||||
|
response.emplace("event", "train");
|
||||||
|
response.emplace("throttle_id", throttleId);
|
||||||
|
response.emplace("train", nullptr);
|
||||||
|
sendMessage(response);
|
||||||
|
}
|
||||||
|
|||||||
@ -49,6 +49,8 @@ protected:
|
|||||||
|
|
||||||
const std::shared_ptr<WebThrottle>& getThrottle(uint32_t throttleId);
|
const std::shared_ptr<WebThrottle>& getThrottle(uint32_t throttleId);
|
||||||
|
|
||||||
|
void released(uint32_t throttleId);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const std::string id;
|
const std::string id;
|
||||||
|
|
||||||
|
|||||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren