diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-14 06:10:47 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 22:56:48 +0200 |
commit | 0c1b3db7c4d9a4bcde4160c437613b32cd4081d6 (patch) | |
tree | 2c6b91d532d8a103b64c7115aec5df21ec644252 | |
parent | 5e15c0bdc0a19f37f54a0f8d2b99145a4350d8c7 (diff) |
Remove subscribed peer from client on disconnect
-rw-r--r-- | src/BootstrapConnection.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/BootstrapConnection.cpp b/src/BootstrapConnection.cpp index 421dfe1..e5f5178 100644 --- a/src/BootstrapConnection.cpp +++ b/src/BootstrapConnection.cpp @@ -6,6 +6,21 @@ namespace sibs { BootstrapConnection::BootstrapConnection(const Ipv4 &bootstrapAddress) { + connections.onRemoveDisconnectedPeer([this](std::shared_ptr<DirectConnectionPeer> peer) + { + std::lock_guard<std::mutex> lock(subscribedPeersMutex); + for(auto &topicUsers : subscribedPeers) + { + for(auto it = topicUsers.second.begin(); it != topicUsers.second.end(); ) + { + if(peer->address == (*it)->address) + it = topicUsers.second.erase(it); + else + ++it; + } + } + }); + PubSubResult connectResult = PubSubResult::OK; std::string connectResultStr; bool connected = false; |