FIX: fixed some issues with subscribung and unsubscribing from topics

This commit is contained in:
Henry Winkel
2023-01-18 11:21:57 +01:00
parent f7d57ccbb8
commit 49bdb28535
7 changed files with 83 additions and 40 deletions

View File

@@ -11,6 +11,7 @@
#include <WHISPER/whisper.hpp>
#include <cstddef>
#include <cstring>
#include <iterator>
/**
* @brief namespace for all whisper-com related components
@@ -30,7 +31,7 @@ namespace WHISPER
this->derivedConnect();
receiveThread = std::thread(&WHISPER::whispercomm::receive,this);
this->setConnected(true);
}
void whispercomm::disconnect()
@@ -38,7 +39,7 @@ namespace WHISPER
stopReceiveThread = true;
if(receiveThread.joinable()) receiveThread.join();
derivedDisconnect();
this->setConnected(false);
}
void whispercomm::publish(std::string msg,std::string topic){
@@ -70,7 +71,8 @@ namespace WHISPER
}
void whispercomm::unsubscribe(std::string topic)
{
{
for (std::vector<std::string>::iterator it = subscribedTopics.begin(); it != subscribedTopics.end();it++)
{
if (*it == topic)
@@ -105,5 +107,13 @@ namespace WHISPER
}
void whispercomm::setConnected(bool val){
this->Connected = val;
}
bool whispercomm::isConnected()
{
return this->Connected;
}
// Add datatypes here
} // namespace WHISPER