correction de notify()

This commit is contained in:
DTux committed 2026-04-13 16:34:08 +02:00
1 parent f80313eaa5
commit 40c4c7fae3
1 file changed
+6 -7
+6 -7
View File
@@ -5,12 +5,12 @@
#include <cstring> #include <cstring>
#include <unistd.h> #include <unistd.h>
#include <QtGlobal> #include <QtGlobal>
#include <iostream>
#include <QList> #include <QList>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <QtHttpServer/QHttpServer> #include <QtHttpServer/QHttpServer>
#include <QtHttpServer/QHttpServerRequest> #include <QtHttpServer/QHttpServerRequest>
#include <QHttpServerResponse>
#include <curl/curl.h> #include <curl/curl.h>
#include <QtMath> #include <QtMath>
#include <QImage> #include <QImage>
@@ -92,17 +92,15 @@ Pws2mqtt::~Pws2mqtt()
void Pws2mqtt::init() void Pws2mqtt::init()
{ {
debug(DEBUGMACRO, "init http server", DEBUG); debug(DEBUGMACRO, "init http server", DEBUG);
httpServer->setMissingHandler([](const QHttpServerRequest &request, QHttpServerResponder &&responder) httpServer->setMissingHandler(httpServer,[](const QHttpServerRequest &request, QHttpServerResponder &responder)
{ {
(void) responder;
debug(DEBUGMACRO, "body " + request.url().toString(), WARNING); debug(DEBUGMACRO, "body " + request.url().toString(), WARNING);
return QHttpServerResponse("404 - Page non trouvée. Route par défaut.", QHttpServerResponse::StatusCode::NotFound); //responder.write(QHttpServerResponse(QString("404 - Page non trouvée. Route par défaut."), QHttpServerResponse::StatusCode::NotFound));
//responder.write(QHttpServerResponse("404 - Page non trouvée. Route par défaut.", QHttpServerResponse::StatusCode::NotFound)); responder.write(QByteArray("404 - Page non trouvée. Route par défaut."), "text/plain", QHttpServerResponse::StatusCode::NotFound);
}); });
httpServer->route("/", [](const QHttpServerRequest &request) httpServer->route("/", [](const QHttpServerRequest &request)
{ {
QList<std::pair<QByteArray, QByteArray>> headersList = request.headers().toList();
debug(DEBUGMACRO, "Remote address" + request.remoteAddress().toString(), WARNING); debug(DEBUGMACRO, "Remote address" + request.remoteAddress().toString(), WARNING);
return QHttpServerResponse("text/plain", "Failed\n"); return QHttpServerResponse("text/plain", "Failed\n");
}); });
@@ -137,7 +135,8 @@ void Pws2mqtt::listeningHttp()
{ {
//QByteArray data; //QByteArray data;
debug (DEBUGMACRO, "listening http requests", DEBUG); debug (DEBUGMACRO, "listening http requests", DEBUG);
const auto port = httpServer->listen(QHostAddress::Any, 5000); QTcpServer *tcpServer = new QTcpServer(this);
const auto port =tcpServer->listen(QHostAddress::Any, 5000);
if (!port) if (!port)
{ {
debug(DEBUGMACRO, "Http Server failed to listen on a port.", ERROR); debug(DEBUGMACRO, "Http Server failed to listen on a port.", ERROR);