forked from Research/WhisperCom
FIX: only subscripe to topic if not yet subscribed
This commit is contained in:
parent
f69010a6e6
commit
6a8f754117
@ -283,11 +283,19 @@ void WhisperCom::Router::processLocalMessage_(zmq::message_t &msg)
|
||||
}
|
||||
else if (rmsg.type() == WhisperCom::Protobuf::RouterMessageType::SUBSCRIBE)
|
||||
{
|
||||
DLOG_S(INFO) << "subscription request from " << sender << " topic: " << rmsg.topic();
|
||||
std::lock_guard<std::mutex> guard{mutexSubscription_};
|
||||
typeName="Subscribe";
|
||||
subscription_[rmsg.topic()].push_back(sender);
|
||||
|
||||
auto it = subscription_.find(rmsg.topic());
|
||||
if (it == subscription_.end() || (*it).second.empty())
|
||||
{
|
||||
listening_.join(rmsg.topic().c_str());
|
||||
}
|
||||
|
||||
subscription_[rmsg.topic()].push_back(sender);
|
||||
|
||||
}
|
||||
else if (rmsg.type() == WhisperCom::Protobuf::RouterMessageType::UNSUBSCRIBE)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard{mutexSubscription_};
|
||||
|
Loading…
Reference in New Issue
Block a user