FIX:fixed issue of unsubscribing while stopping the service
This commit is contained in:
@@ -91,13 +91,13 @@ namespace WHISPER {
|
|||||||
{
|
{
|
||||||
WHISPER::Leave Leave(getParentID(),getOwnID(),getOwnDeviceType(),ownReceivingPort_,myAdress_);
|
WHISPER::Leave Leave(getParentID(),getOwnID(),getOwnDeviceType(),ownReceivingPort_,myAdress_);
|
||||||
this->publish(Leave.serialize(),WHISPER::MsgTopicsMap[(WHISPER::MsgTopics)Leave.topic_]);
|
this->publish(Leave.serialize(),WHISPER::MsgTopicsMap[(WHISPER::MsgTopics)Leave.topic_]);
|
||||||
unsubscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::MANAGEMENT]);
|
// unsubscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::MANAGEMENT]);
|
||||||
|
|
||||||
if (subscribedTopics.size() > 0) {
|
// if (subscribedTopics.size() > 0) {
|
||||||
for ( std::vector<std::string>::iterator it = subscribedTopics.begin(); it != subscribedTopics.end(); it++) {
|
// for ( std::vector<std::string>::iterator it = subscribedTopics.begin(); it != subscribedTopics.end(); it++) {
|
||||||
unsubscribe(*it);
|
// unsubscribe(*it);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ namespace WHISPER
|
|||||||
|
|
||||||
void whispercomm::disconnect()
|
void whispercomm::disconnect()
|
||||||
{
|
{
|
||||||
|
if (subscribedTopics.size() > 0) {
|
||||||
|
for ( std::vector<std::string>::iterator it = subscribedTopics.begin(); it != subscribedTopics.end(); it++) {
|
||||||
|
unsubscribe(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stopReceiveThread = true;
|
stopReceiveThread = true;
|
||||||
if(receiveThread.joinable()) receiveThread.join();
|
if(receiveThread.joinable()) receiveThread.join();
|
||||||
derivedDisconnect();
|
derivedDisconnect();
|
||||||
|
|||||||
Reference in New Issue
Block a user