From 168fa4889c230de9016e1371e65da49a8d36e16c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 25 Nov 2018 00:22:29 +0100 Subject: Remove duplicate user add if same pubsub key, do not add user until connected --- src/BootstrapConnection.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/BootstrapConnection.cpp') diff --git a/src/BootstrapConnection.cpp b/src/BootstrapConnection.cpp index d914646..f09547e 100644 --- a/src/BootstrapConnection.cpp +++ b/src/BootstrapConnection.cpp @@ -127,6 +127,15 @@ namespace sibs Log::warn("BootstrapConnection::receiveDataFromServer: No listener found for key '%s', ignoring...", pubsubKey.toString().c_str()); return; } + + for(auto existingPeer : subscribeDataIt->second.peers) + { + if(peer == existingPeer) + { + Log::debug("BootstrapConnection::receiveDataFromServer: Already connected to peer (ip: %s, port: %d)", peer->address.getAddress().c_str(), peer->address.getPort()); + return; + } + } subscribeDataIt->second.peers.push_back(peer); Log::debug("BootstrapConnection::receiveDataFromServer: Connected to peer (ip: %s, port: %d) given by bootstrap node", peer->address.getAddress().c_str(), peer->address.getPort()); } -- cgit v1.2.3