void ConnectionManager::Inquired(const Response &response) { QSharedPointer<Edge> edge = response.GetFrom().dynamicCast<Edge>(); if(!edge) { qWarning() << "Received an inquired from a non-Edge: " << response.GetFrom()->ToString(); return; } else if(!edge->Outbound()) { qWarning() << "We would never make an inquire call on an" << "incoming edge: " << response.GetFrom()->ToString(); return; } QByteArray brem_id = response.GetData().toByteArray(); if(brem_id.isEmpty()) { qWarning() << "Invalid ConnectionEstablished, no id"; return; } Id rem_id(brem_id); if(_local_id < rem_id) { BindEdge(edge, rem_id); } else if(rem_id == _local_id) { Address addr = edge->GetRemoteAddress(); qDebug() << "Attempting to connect to ourself"; edge->Stop("Attempting to connect to ourself"); emit ConnectionAttemptFailure(addr, "Attempting to connect to ourself"); } }
void RpcHandler::HandleResponse(const Response &response) { int id = response.GetId(); if(id == 0) { #ifdef RESPOND_NOTIFICATION if(response.GetData().toString() == Request::NotificationType) { return; } #endif qWarning() << "RpcHandler: Response: No ID, from" << response.GetFrom()->ToString(); return; } QSharedPointer<RequestState> state = _requests[id]; if(!state) { if(response.GetData().toString() == Request::NotificationType) { return; } qWarning() << "RpcHandler: Response: No handler for" << id; return; } if(state->GetSender() != response.GetFrom()) { qDebug() << "Received a response from a different source than " << "the path the request was sent by. Sent by:" << state->GetSender()->ToString() << "Received by:" << response.GetFrom()->ToString(); // Eventually we need to not allow this behavior, but that means making // better equality comparator } state->StopTimer(); _requests.remove(id); state->GetResponseHandler()->RequestComplete(response); }
void CSConnectionAcquirer::ServerStateResponse(const Response &response) { QSharedPointer<Connection> con = response.GetFrom().dynamicCast<Connection>(); if(!con) { qCritical() << "Received an rpc request from a non-connection."; return; } Id remote = con->GetRemoteId(); QVariantHash msg = response.GetData().toHash(); QHash<QByteArray, QUrl> id_to_addr; QDataStream stream(msg.value("list").toByteArray()); stream >> id_to_addr; int cons = msg.value("connections").toInt(); if(IsServer()) { ServerHandleServerStateResponse(remote, id_to_addr, cons); } else { ClientHandleServerStateResponse(remote, id_to_addr, cons); } }