forked from Research/WhisperCom
FIX: only subscripe to topic if not yet subscribed
This commit is contained in:
parent
f69010a6e6
commit
6a8f754117
@ -283,10 +283,18 @@ void WhisperCom::Router::processLocalMessage_(zmq::message_t &msg)
|
|||||||
}
|
}
|
||||||
else if (rmsg.type() == WhisperCom::Protobuf::RouterMessageType::SUBSCRIBE)
|
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_};
|
std::lock_guard<std::mutex> guard{mutexSubscription_};
|
||||||
typeName="Subscribe";
|
typeName="Subscribe";
|
||||||
|
|
||||||
|
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);
|
subscription_[rmsg.topic()].push_back(sender);
|
||||||
listening_.join(rmsg.topic().c_str());
|
|
||||||
}
|
}
|
||||||
else if (rmsg.type() == WhisperCom::Protobuf::RouterMessageType::UNSUBSCRIBE)
|
else if (rmsg.type() == WhisperCom::Protobuf::RouterMessageType::UNSUBSCRIBE)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user