本文整理汇总了C++中QSharedPointer::GetRemoteId方法的典型用法代码示例。如果您正苦于以下问题:C++ QSharedPointer::GetRemoteId方法的具体用法?C++ QSharedPointer::GetRemoteId怎么用?C++ QSharedPointer::GetRemoteId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSharedPointer
的用法示例。
在下文中一共展示了QSharedPointer::GetRemoteId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IncomingData
void RepeatingBulkRound::IncomingData(const Request ¬ification)
{
if(Stopped()) {
qWarning() << "Received a message on a closed session:" << ToString();
return;
}
QSharedPointer<Connections::IOverlaySender> sender =
notification.GetFrom().dynamicCast<Connections::IOverlaySender>();
if(!sender) {
qDebug() << ToString() << " received wayward message from: " <<
notification.GetFrom()->ToString();
return;
}
const Id &id = sender->GetRemoteId();
if(!GetGroup().Contains(id)) {
qDebug() << ToString() << " received wayward message from: " <<
notification.GetFrom()->ToString();
return;
}
QVariantHash msg = notification.GetData().toHash();
bool bulk = msg.value("bulk").toBool();
if(bulk) {
ProcessData(id, msg.value("data").toByteArray());
} else {
_shuffle_round->IncomingData(notification);
}
}
示例2: HandleEdgeClose
void ConnectionManager::HandleEdgeClose()
{
Edge *edge = qobject_cast<Edge *>(sender());
_active_addrs.remove(edge->GetRemoteAddress());
qDebug() << "Edge closed: " << edge->ToString() << edge->GetStoppedReason();
if(!_con_tab.RemoveEdge(edge)) {
qWarning() << "Edge closed but no Edge found in CT:" << edge->ToString();
}
QSharedPointer<Connection> con = _con_tab.GetConnection(edge);
if(con) {
con = _con_tab.GetConnection(con->GetRemoteId());
if(con) {
con->Disconnect();
}
}
if(!Stopped()) {
return;
}
if(_con_tab.GetEdges().count() == 0) {
emit Disconnected();
}
}
示例3: EdgeCheck
void ConnectionManager::EdgeCheck(const int &)
{
qDebug() << "Checking edges";
QList<QSharedPointer<Edge> > edges_to_close;
qint64 now = Utils::Time::GetInstance().MSecsSinceEpoch();
qint64 check_time = now - EdgeCheckTimeout;
qint64 close_time = now - EdgeCloseTimeout;
foreach(const QSharedPointer<Edge> &edge, _con_tab.GetEdges()) {
qint64 last_msg = edge->GetLastIncomingMessage();
if(check_time < last_msg) {
continue;
} else if(last_msg < close_time) {
QSharedPointer<Connection> con = _con_tab.GetConnection(edge.data());
if(con && (con->GetRemoteId() == _local_id)) {
qDebug() << "Attempted to close loopback connection.";
continue;
}
qDebug() << "Closing edge:" << edge->ToString();
edge->Stop("Timed out");
} else {
QSharedPointer<Messaging::ISender> sender = _con_tab.GetConnection(edge.data());
if(!sender) {
sender = edge;
}
qDebug() << "Testing:" << sender->ToString();
_rpc->SendRequest(sender, "CM::Ping", QVariant(), _ping_handler, true);
}
}
}
示例4: IncomingData
void Round::IncomingData(const Request ¬ification)
{
if(Stopped()) {
qWarning() << "Received a message on a closed session:" << ToString();
return;
}
QSharedPointer<Connections::IOverlaySender> sender =
notification.GetFrom().dynamicCast<Connections::IOverlaySender>();
if(!sender) {
qDebug() << ToString() << " received wayward message from: " <<
notification.GetFrom()->ToString();
return;
}
const Id &id = sender->GetRemoteId();
if(!_group.Contains(id)) {
qDebug() << ToString() << " received wayward message from: " <<
notification.GetFrom()->ToString();
return;
}
ProcessData(id, notification.GetData().toHash().value("data").toByteArray());
}
示例5: Forward
void RelayForwarder::Forward(const Id &to, const QByteArray &data,
const QStringList &been)
{
QHash<int, bool> tested;
QSharedPointer<Connection> con = _ct.GetConnection(to);
if(!con || (dynamic_cast<RelayEdge *>(con->GetEdge().data()) != 0)) {
if(!been.contains(Preferred().ToString())) {
con = _ct.GetConnection(Preferred());
}
}
if(!con || (dynamic_cast<RelayEdge *>(con->GetEdge().data()) != 0)) {
const QList<QSharedPointer<Connection> > cons = _ct.GetConnections();
Dissent::Utils::Random &rand = Dissent::Utils::Random::GetInstance();
int idx = rand.GetInt(0, cons.size());
con = cons[idx];
tested[idx] = true;
RelayEdge *redge = dynamic_cast<RelayEdge *>(con->GetEdge().data());
while(been.contains(con->GetRemoteId().ToString()) || (redge != 0)) {
if(tested.size() == cons.size()) {
qWarning() << "Packet has been to all of our connections.";
return;
}
idx = rand.GetInt(0, cons.size());
con = cons[idx];
redge = dynamic_cast<RelayEdge *>(con->GetEdge().data());
tested[idx] = true;
}
}
Send(con, to, data, been);
}
示例6: IncomingDataSpecial
void BaseBulkRound::IncomingDataSpecial(const Request ¬ification)
{
QVariantHash msg = notification.GetData().toHash();
if(msg.value("bulk", false).toBool()) {
QSharedPointer<Connections::IOverlaySender> sender =
notification.GetFrom().dynamicCast<Connections::IOverlaySender>();
const Id &id = sender->GetRemoteId();
ProcessData(id, msg.value("data").toByteArray());
} else {
_shuffle_round->IncomingData(notification);
}
}
示例7: Send
void RelayForwarder::Send(const QSharedPointer<Connection> &con,
const Id &to, const QByteArray &data, const QStringList &been,
const QStringList &reverse)
{
QVariantHash msg;
msg["to"] = to.ToString();
msg["data"] = data;
msg["been"] = been + _base_been;
if(!reverse.isEmpty()) {
msg["reverse"] = reverse;
}
qDebug() << con->GetLocalId().ToString() << "Forwarding message from" <<
msg["been"].toStringList().value(0) << "to" << to.ToString() << "via" <<
con->GetRemoteId().ToString() << "Reverse path" << !reverse.isEmpty();
_rpc->SendNotification(con, "RF::Data", msg);
}
示例8: ServerStateResponse
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);
}
}