first version of InternalUDPService
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
*/
|
||||
|
||||
#include <WHISPER/whisper.hpp>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
/**
|
||||
* @brief namespace for all whisper-com related components
|
||||
*/
|
||||
@@ -18,27 +20,30 @@ namespace WHISPER
|
||||
|
||||
|
||||
|
||||
void whispercomm::connect(std::shared_ptr<threadSafeQueue<std::string>> receiver)
|
||||
void whispercomm::connect(std::shared_ptr<threadSafeQueue<WHISPER::Message>> receiver)
|
||||
{
|
||||
this->receiveQueue = receiver;
|
||||
this->derivedConnect();
|
||||
|
||||
receiveThread = std::thread(&WHISPER::whispercomm::receive,this);
|
||||
|
||||
}
|
||||
|
||||
void whispercomm::disconnect()
|
||||
{
|
||||
|
||||
derivedDisconnect();
|
||||
}
|
||||
|
||||
void whispercomm::publish(std::string msg){
|
||||
this->derivedPublish(msg);
|
||||
void whispercomm::publish(std::string msg,std::string topic){
|
||||
this->derivedPublish(msg,topic);
|
||||
}
|
||||
|
||||
void whispercomm::receive(){
|
||||
this->derivedReceive();
|
||||
|
||||
connected = true;
|
||||
|
||||
derivedReceive();
|
||||
|
||||
while(!stopReceiveThread)
|
||||
{
|
||||
derivedReceive();
|
||||
@@ -50,6 +55,7 @@ namespace WHISPER
|
||||
void whispercomm::subscribe(std::string topic)
|
||||
{
|
||||
this->subscribedTopics.push_back(topic);
|
||||
derivedSubscribe(topic);
|
||||
}
|
||||
|
||||
void whispercomm::unsubscribe(std::string topic)
|
||||
@@ -61,12 +67,23 @@ namespace WHISPER
|
||||
it = subscribedTopics.erase(it);
|
||||
}
|
||||
}
|
||||
derivedUnsubscribe(topic);
|
||||
|
||||
}
|
||||
|
||||
void whispercomm::addMsgToReceiverQueue(std::string)
|
||||
void whispercomm::addMsgToReceiverQueue(WHISPER::Message msg)
|
||||
{
|
||||
if (this->receiveQueue != nullptr)
|
||||
{
|
||||
|
||||
this->receiveQueue->addElement(msg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void whispercomm::setGateway(bool val)
|
||||
{
|
||||
gateway = val;
|
||||
}
|
||||
|
||||
// Add datatypes here
|
||||
|
||||
Reference in New Issue
Block a user