void BufferEdgeListener::CreateEdgeTo(const Address &to) { const BufferAddress &rem_ba = static_cast<const BufferAddress &>(to); BufferEdgeListener *remote_el = _el_map[rem_ba.GetId()]; if(remote_el == 0) { qDebug() << "Attempting to create an Edge to an EL that doesn't exist from " << _local_address.ToString() << " to " << to.ToString(); return; } BufferEdge *local_edge(new BufferEdge(_local_address, remote_el->_local_address, true, 10)); BufferEdge *remote_edge(new BufferEdge(remote_el->_local_address, _local_address, false, 10)); local_edge->SetRemoteEdge(remote_edge); remote_edge->SetRemoteEdge(local_edge); ProcessNewEdge(local_edge); remote_el->ProcessNewEdge(remote_edge); }
void BufferEdgeListener::CreateEdgeTo(const Address &to) { if(Stopped()) { qWarning() << "Cannot CreateEdgeTo Stopped EL"; return; } if(!Started()) { qWarning() << "Cannot CreateEdgeTo non-Started EL"; return; } const BufferAddress &rem_ba = static_cast<const BufferAddress &>(to); BufferEdgeListener *remote_el = _el_map.value(rem_ba.GetId()); if(remote_el == 0) { qDebug() << "Attempting to create an Edge to an EL that doesn't exist from " << GetAddress().ToString() << " to " << to.ToString(); ProcessEdgeCreationFailure(to, "No such peer"); return; } int delay = Dissent::Utils::Random::GetInstance().GetInt(10, 50); BufferEdge *local_edge(new BufferEdge(GetAddress(), remote_el->GetAddress(), true, delay)); BufferEdge *remote_edge(new BufferEdge(remote_el->GetAddress(), GetAddress(), false, delay)); QSharedPointer<BufferEdge> ledge(local_edge); SetSharedPointer(ledge); QSharedPointer<BufferEdge> redge(remote_edge); SetSharedPointer(redge); local_edge->SetRemoteEdge(redge); remote_edge->SetRemoteEdge(ledge); ProcessNewEdge(ledge); remote_el->ProcessNewEdge(redge); }