std::shared_ptr<ServerPeerInfo> speer =
std::dynamic_pointer_cast<ServerPeerInfo>(peer);
LOG(INFO) << "Disconnect !! " << speer->GetClientDp();
- for (std::shared_ptr<PeerInfo> i : peerlist_) {
- std::shared_ptr<ServerPeerInfo> si =
- std::dynamic_pointer_cast<ServerPeerInfo>(i);
- if (*si->GetClientDp() == *speer->GetClientDp())
- peerlist_.remove(i);
- }
- for (VineDpPtr ptr : accepted_dp_list_) {
- if (*ptr == *speer->GetClientDp())
- accepted_dp_list_.remove(ptr);
- }
+ peerlist_.erase(std::remove_if(peerlist_.begin(), peerlist_.end(),
+ [speer](std::shared_ptr<PeerInfo> i) -> bool {
+ std::shared_ptr<ServerPeerInfo> si =
+ std::dynamic_pointer_cast<ServerPeerInfo>(i);
+ if (*si->GetClientDp() == *speer->GetClientDp())
+ return true;
+ return false;
+ }));
+
+ accepted_dp_list_.erase(
+ std::remove_if(accepted_dp_list_.begin(), accepted_dp_list_.end(),
+ [speer](VineDpPtr ptr) -> bool {
+ if (*ptr == *speer->GetClientDp())
+ return true;
+ return false;
+ }));
}
void ServerChannel::Impl::Accept(std::shared_ptr<PeerInfo> peer_info) {
return;
}
- InvokeAtIdle(this, [this, peer_copy = *peer]() -> void {
+ InvokeAtIdle(this, [this, peer]() -> void {
ConnectionResult result(ConnectionResult::OK);
- auto p = std::make_shared<PeerInfo>(peer_copy);
- this->OnConnectionResult(p, result);
+ this->OnConnectionResult(peer, result);
});
}
return;
}
- InvokeAtIdle(this, [this, peer_copy = *peer]() -> void {
+ InvokeAtIdle(this, [this, peer]() -> void {
ConnectionResult result(ConnectionResult::Rejected);
- auto p = std::make_shared<PeerInfo>(peer_copy);
- this->OnConnectionResult(p, result);
+ this->OnConnectionResult(peer, result);
});
}