Add reboot all functionality in espremotemanager

This commit is contained in:
2022-09-26 14:16:31 +02:00
parent 68a17e2442
commit 55be773896
2 changed files with 15 additions and 0 deletions

View File

@@ -27,6 +27,10 @@ void EspRemoteManager::requestReceived(WebserverClientConnection &client, const
{
sendRootResponse(client, url, query);
}
else if (url.path() == "/rebootAll")
{
sendRebootAllResponse(client, url, query);
}
else if (url.path() == "/reboot")
{
sendRebootResponse(client, url, query);
@@ -65,6 +69,7 @@ void EspRemoteManager::sendRootResponse(WebserverClientConnection &client, const
"</head>"
"<body>"
"<h1>ESP Remote Manager</h1>"
"<a href=\"rebootAll\">Reboot all</a>"
"<table class=\"table table-striped table-bordered table-sm\" style=\"width: initial;\">"
"<thead>"
"<tr>"
@@ -112,6 +117,15 @@ void EspRemoteManager::sendRootResponse(WebserverClientConnection &client, const
qWarning() << "sending response failed";
}
void EspRemoteManager::sendRebootAllResponse(WebserverClientConnection &client, const QUrl &url, const QUrlQuery &query)
{
for (auto client : m_clients)
client->reboot();
if (!client.sendFullResponse(200, "Ok", {{"Content-Type", "text/plain"}}, "peer reboot commands sent!"))
qWarning() << "sending response failed";
}
void EspRemoteManager::sendRebootResponse(WebserverClientConnection &client, const QUrl &url, const QUrlQuery &query)
{
if (!query.hasQueryItem("peer"))

View File

@@ -24,6 +24,7 @@ private slots:
private:
void sendRootResponse(WebserverClientConnection &client, const QUrl &url, const QUrlQuery &query);
void sendRebootAllResponse(WebserverClientConnection &client, const QUrl &url, const QUrlQuery &query);
void sendRebootResponse(WebserverClientConnection &client, const QUrl &url, const QUrlQuery &query);
QWebSocketServer &m_websocketServer;