当前位置: 首页>>代码示例>>C++>>正文


C++ QSharedPointer::GetEdge方法代码示例

本文整理汇总了C++中QSharedPointer::GetEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ QSharedPointer::GetEdge方法的具体用法?C++ QSharedPointer::GetEdge怎么用?C++ QSharedPointer::GetEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSharedPointer的用法示例。


在下文中一共展示了QSharedPointer::GetEdge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:benjaminp,项目名称:Dissent,代码行数:35,代码来源:RelayForwarder.cpp

示例2: ServerStateInquire

  void CSConnectionAcquirer::ServerStateInquire(const Request &request)
  {
    QHash<QByteArray, QUrl> id_to_addr;
    const Id &my_id = GetConnectionManager()->GetId();
    const ConnectionTable &ct = GetConnectionManager()->GetConnectionTable();

    foreach(const PublicIdentity &gc, _group.GetSubgroup()) {
      const Id &gc_id = gc.GetId();
      if(gc_id == my_id) {
        continue;
      }

      QSharedPointer<Connection> con = ct.GetConnection(gc_id);
      if(!con) {
        continue;
      }

      id_to_addr[gc_id.GetByteArray()] =
        con->GetEdge()->GetRemotePersistentAddress().GetUrl();
    }

    QByteArray slm;
    QDataStream out_stream(&slm, QIODevice::WriteOnly);
    out_stream << id_to_addr;

    QVariantHash msg;
    msg["connections"] = ct.GetConnections().size();
    msg["list"] = slm;
    request.Respond(msg);
  }
开发者ID:ASchurman,项目名称:Dissent,代码行数:30,代码来源:CSConnectionAcquirer.cpp

示例3: Disconnect

  void ConnectionManager::Disconnect(const Request &notification)
  {
    QSharedPointer<Connection> con =
      notification.GetFrom().dynamicCast<Connection>();

    if(!con) {
      qWarning() << "Received DisconnectResponse from a non-connection: " <<
        notification.GetFrom()->ToString();
      return;
    }

    qDebug() << "Received disconnect for: " << con->ToString();
    _con_tab.Disconnect(con.data());
    con->GetEdge()->Stop("Remote disconnect");
  }
开发者ID:ASchurman,项目名称:Dissent,代码行数:15,代码来源:ConnectionManager.cpp

示例4: Reverse

bool RelayForwarder::Reverse(const Id &to, const QByteArray &data,
                             const QStringList &been, const QStringList &reverse)
{
    if(to != Id(reverse.value(0))) {
        qDebug() << "to and starting position are not equal" << reverse << reverse.isEmpty();
    }
    QSharedPointer<Connection> con;
    QStringList nreverse;
    for(int idx = 0; idx < reverse.count(); idx++) {
        con = _ct.GetConnection(Id(reverse[idx]));
        if(con && !con->GetEdge().dynamicCast<RelayEdge>()) {
            Send(con, to, data, been, reverse.mid(0, idx));
            return true;
        }
    }

    return false;
}
开发者ID:benjaminp,项目名称:Dissent,代码行数:18,代码来源:RelayForwarder.cpp


注:本文中的QSharedPointer::GetEdge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。