Skip to content

Commit

Permalink
modified: src/v2i-hub/CommandPlugin/src/CommandPlugin.cpp
Browse files Browse the repository at this point in the history
	modified:   src/v2i-hub/PedestrianPlugin/src/PedestrianPlugin.cpp
	modified:   src/v2i-hub/PedestrianPlugin/src/include/PedestrianPlugin.hpp
  • Loading branch information
jwillmartin committed Jun 28, 2024
1 parent 3f14af6 commit 30b5ff2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/v2i-hub/CommandPlugin/src/CommandPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,10 @@ int CommandPlugin::WSCallbackBASE64(
argsList[arg.first] = arg.second.data();
}
}
catch (exception &argsEx)
catch (const exception &argsEx)
{
//no args
FILE_LOG(logDEBUG) << "WSCallbackBASE64 process command error: no arguments";
FILE_LOG(logDEBUG) << "WSCallbackBASE64 process command error: no arguments. " << argsEx.what();
}

//check authorization
Expand Down
17 changes: 12 additions & 5 deletions src/v2i-hub/PedestrianPlugin/src/PedestrianPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace PedestrianPlugin
*
* @param name The name to give the plugin for identification purposes.
*/
PedestrianPlugin::PedestrianPlugin(const std::string &name) : PluginClient(name), runningWebSocket(false), runningWebService(false)
PedestrianPlugin::PedestrianPlugin(const std::string &name) : PluginClient(name)
{
if (_signSimClient != nullptr)
_signSimClient.reset();
Expand All @@ -31,12 +31,14 @@ PedestrianPlugin::PedestrianPlugin(const std::string &name) : PluginClient(name)

std::thread webServiceThread(&PedestrianPlugin::StartWebService, this);
webServiceThread.detach(); // wait for the thread to finish
// StartWebService = std::move(std::jthread{StartWebService});
runningWebService = true;
}

int PedestrianPlugin::StartWebSocket()
{
PLOG(logDEBUG) << "In PedestrianPlugin::StartWebSocket ";
// std::jthread StartWebSocket;

flirSession = std::make_shared<FLIRWebSockAsyncClnSession>(ioc);

Expand Down Expand Up @@ -71,6 +73,7 @@ void PedestrianPlugin::StopWebSocket()

[[noreturn]] int PedestrianPlugin::checkXML()
{
// std::jthread checkXML;
//if a new psm xml has been generated the FLIR web socket, send it to the BroadcastPSM function
while (true)
{
Expand All @@ -85,7 +88,7 @@ void PedestrianPlugin::StopWebSocket()

while(!currentPSMQueue.empty())
{
char* char_arr = &currentPSMQueue.front()[0];
const char* char_arr = &currentPSMQueue.front()[0];

BroadcastPsm(char_arr);
currentPSMQueue.pop();
Expand Down Expand Up @@ -119,7 +122,7 @@ void PedestrianPlugin::PedestrianRequestHandler(QHttpEngine::Socket *socket)

// Catch parse exceptions
try {
for(const auto psm_s: psmSL)
for(const auto& psm_s: psmSL)
{
BroadcastPsm(psm_s);
socket->setStatusCode(QHttpEngine::Socket::Created);
Expand All @@ -137,7 +140,8 @@ void PedestrianPlugin::PedestrianRequestHandler(QHttpEngine::Socket *socket)
int PedestrianPlugin::StartWebService()
{
PLOG(logDEBUG) << "In PedestrianPlugin::StartWebService";

// std::jthread webServiceThread;

// Web services
std::array<char*, 1> placeholderX = {nullptr};
int placeholderC = 1;
Expand Down Expand Up @@ -199,11 +203,13 @@ void PedestrianPlugin::UpdateConfigSettings()
{
PLOG(logDEBUG) << "Starting WebSocket Thread";
std::thread webSocketThread(&PedestrianPlugin::StartWebSocket, this);
// StartWebSocket = std::move(std::jthread{StartWebSocket});
PLOG(logDEBUG) << "WebSocket Thread started!!";
webSocketThread.detach(); // wait for the thread to finish

PLOG(logDEBUG) << "Starting XML Thread";
std::thread xmlThread(&PedestrianPlugin::checkXML, this);
// checkXML = std::move(std::jthread{checkXML});
PLOG(logDEBUG) << "XML Thread started!!";
xmlThread.detach(); // wait for the thread to finish
}
Expand Down Expand Up @@ -259,7 +265,8 @@ void PedestrianPlugin::BroadcastPsm(const std::string &psmJson)

psmENC.encode_j2735_message(psmmessage);

std::unique_ptr<PsmEncodedMessage> msg(new PsmEncodedMessage());
// std::unique_ptr<PsmEncodedMessage> msg;
auto msg = std::make_unique<PsmEncodedMessage>();
msg.reset();
msg.reset(dynamic_cast<PsmEncodedMessage*>(factory.NewMessage(api::MSGSUBTYPE_PERSONALSAFETYMESSAGE_STRING)));

Expand Down
8 changes: 2 additions & 6 deletions src/v2i-hub/PedestrianPlugin/src/include/PedestrianPlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,8 @@ class PedestrianPlugin: public PluginClient
std::shared_ptr<FLIRWebSockAsyncClnSession> flirSession;
std::string hostString;

std::thread webSocketThread;
std::thread xmlThread;
std::thread webServiceThread;

std::atomic<bool> runningWebSocket;
std::atomic<bool> runningWebService;
bool runningWebSocket = false;
bool runningWebService = false;

// The io_context is required for all I/O
net::io_context ioc;
Expand Down

0 comments on commit 30b5ff2

Please sign in to comment.