Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Apr 13, 2024
1 parent 9fef692 commit 47370d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/v2i-hub/CARMACloudPlugin/src/CARMACloudPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,25 +463,14 @@ int CARMACloudPlugin::StartWebService()
QHostAddress address = QHostAddress(QString::fromStdString (webip));
quint16 port = static_cast<quint16>(webport);

QSharedPointer<OpenAPI::OAIApiRequestHandler> handler(new OpenAPI::OAIApiRequestHandler());
handler = QSharedPointer<OpenAPI::OAIApiRequestHandler> (new OpenAPI::OAIApiRequestHandler());

auto router = QSharedPointer<OpenAPI::OAIApiRouter>::create();
router->setUpRoutes();

QObject::connect(handler.data(), &OpenAPI::OAIApiRequestHandler::requestReceived, [&](QHttpEngine::Socket *socket) {

CARMAResponseHandler(socket);
});

QObject::connect(handler.data(), &OpenAPI::OAIApiRequestHandler::requestReceived, [&](QHttpEngine::Socket *socket) {

router->processRequest(socket);
});

QHttpEngine::Server server(handler.data());

if (!server.listen(address, port)) {
QHttpEngine::QObjectHandler apiHandler;
apiHandler.registerMethod(TCM_REPLY, [&](QHttpEngine::Socket *socket)
{
CARMAResponseHandler(socket);
socket->close(); });
QHttpEngine::Server server(&apiHandler);

if (!server.listen(address, port)) {
qCritical("Unable to listen on the specified port.");
return 1;
}
Expand Down
3 changes: 3 additions & 0 deletions src/v2i-hub/CARMACloudPlugin/src/CARMACloudPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include <unistd.h>
#endif
#include <qhttpengine/server.h>
#include <qhttpengine/qobjecthandler.h>
#include <v2xhubWebAPI/OAIApiRouter.h>


Expand Down Expand Up @@ -210,6 +211,8 @@ class CARMACloudPlugin: public PluginClient {
const char *CONTENT_ENCODING_KEY = "Content-Encoding";
const char *CONTENT_ENCODING_VALUE = "gzip";
std::string list_tcm = "true";
//API URL to accept TCM response
const std::string TCM_REPLY="tcmreply";

};
std::mutex _cfgLock;
Expand Down

0 comments on commit 47370d7

Please sign in to comment.