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


C++ SharedNodePointer类代码示例

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


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

示例1: handleEntityScriptGetStatusPacket

void EntityScriptServer::handleEntityScriptGetStatusPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
    if (senderNode->getCanRez() || senderNode->getCanRezTmp() || senderNode->getCanRezCertified() || senderNode->getCanRezTmpCertified()) {
        MessageID messageID;
        message->readPrimitive(&messageID);
        auto entityID = QUuid::fromRfc4122(message->read(NUM_BYTES_RFC4122_UUID));

        auto replyPacketList = NLPacketList::create(PacketType::EntityScriptGetStatusReply, QByteArray(), true, true);
        replyPacketList->writePrimitive(messageID);

        EntityScriptDetails details;
        if (_entitiesScriptEngine->getEntityScriptDetails(entityID, details)) {
            replyPacketList->writePrimitive(true);
            replyPacketList->writePrimitive(details.status);
            replyPacketList->writeString(details.errorInfo);
        } else {
            replyPacketList->writePrimitive(false);
        }

        auto nodeList = DependencyManager::get<NodeList>();
        nodeList->sendPacketList(std::move(replyPacketList), *senderNode);
    }
}
开发者ID:birarda,项目名称:hifi,代码行数:22,代码来源:EntityScriptServer.cpp

示例2: nodeActivated

void ACClientApp::nodeActivated(SharedNodePointer node) {
    if (node->getType() == NodeType::EntityServer) {
        if (_verbose) {
            qDebug() << "saw EntityServer";
        }
        _sawEntityServer = true;
    }
    else if (node->getType() == NodeType::AudioMixer) {
        if (_verbose) {
            qDebug() << "saw AudioMixer";
        }
        _sawAudioMixer = true;
    }
    else if (node->getType() == NodeType::AvatarMixer) {
        if (_verbose) {
            qDebug() << "saw AvatarMixer";
        }
        _sawAvatarMixer = true;
    }
    else if (node->getType() == NodeType::AssetServer) {
        if (_verbose) {
            qDebug() << "saw AssetServer";
        }
        _sawAssetServer = true;
    }
    else if (node->getType() == NodeType::MessagesMixer) {
        if (_verbose) {
            qDebug() << "saw MessagesMixer";
        }
        _sawMessagesMixer = true;
    }

    if (_sawEntityServer && _sawAudioMixer && _sawAvatarMixer && _sawAssetServer && _sawMessagesMixer) {
        if (_verbose) {
            qDebug() << "success";
        }
        finish(0);
    }
}
开发者ID:Menithal,项目名称:hifi,代码行数:39,代码来源:ACClientApp.cpp

示例3: spawnChildClient

void AssignmentClientMonitor::checkSpares() {
    auto nodeList = DependencyManager::get<NodeList>();
    QUuid aSpareId = "";
    unsigned int spareCount = 0;
    unsigned int totalCount = 0;

    nodeList->removeSilentNodes();

    nodeList->eachNode([&](const SharedNodePointer& node) {
        AssignmentClientChildData* childData = static_cast<AssignmentClientChildData*>(node->getLinkedData());
        totalCount ++;
        if (childData->getChildType() == Assignment::Type::AllTypes) {
            ++spareCount;
            aSpareId = node->getUUID();
        }
    });

    // Spawn or kill children, as needed.  If --min or --max weren't specified, allow the child count
    // to drift up or down as far as needed.

    if (spareCount < 1 || totalCount < _minAssignmentClientForks) {
        if (!_maxAssignmentClientForks || totalCount < _maxAssignmentClientForks) {
            spawnChildClient();
        }
    }

    if (spareCount > 1) {
        if (!_minAssignmentClientForks || totalCount > _minAssignmentClientForks) {
            // kill aSpareId
            qDebug() << "asking child" << aSpareId << "to exit.";
            SharedNodePointer childNode = nodeList->nodeWithUUID(aSpareId);
            childNode->activateLocalSocket();

            auto diePacket = NLPacket::create(PacketType::StopNode, 0);
            nodeList->sendPacket(std::move(diePacket), *childNode);
        }
    }
}
开发者ID:Menithal,项目名称:hifi,代码行数:38,代码来源:AssignmentClientMonitor.cpp

示例4: updateNodeWithDataFromPacket

int LimitedNodeList::updateNodeWithDataFromPacket(const SharedNodePointer& matchingNode, const QByteArray &packet) {
    QMutexLocker locker(&matchingNode->getMutex());

    matchingNode->setLastHeardMicrostamp(usecTimestampNow());

    // if this was a sequence numbered packet we should store the last seq number for
    // a packet of this type for this node
    PacketType packetType = packetTypeForPacket(packet);
    if (SEQUENCE_NUMBERED_PACKETS.contains(packetType)) {
        matchingNode->setLastSequenceNumberForPacketType(sequenceNumberFromHeader(packet, packetType), packetType);
    }

    NodeData* linkedData = matchingNode->getLinkedData();
    if (!linkedData && linkedDataCreateCallback) {
        linkedDataCreateCallback(matchingNode.data());
    }

    if (linkedData) {
        QMutexLocker linkedDataLocker(&linkedData->getMutex());
        return linkedData->parseData(packet);
    }
    return 0;
}
开发者ID:Dreckinfeuer,项目名称:hifi,代码行数:23,代码来源:LimitedNodeList.cpp

示例5: hasSpecialPacketsToSend

// EntityServer will use the "special packets" to send list of recently deleted entities
bool EntityServer::hasSpecialPacketsToSend(const SharedNodePointer& node) {
    bool shouldSendDeletedEntities = false;

    // check to see if any new entities have been added since we last sent to this node...
    EntityNodeData* nodeData = static_cast<EntityNodeData*>(node->getLinkedData());
    if (nodeData) {
        quint64 deletedEntitiesSentAt = nodeData->getLastDeletedEntitiesSentAt();

        EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
        shouldSendDeletedEntities = tree->hasEntitiesDeletedSince(deletedEntitiesSentAt);
    }

    return shouldSendDeletedEntities;
}
开发者ID:GabrielPathfinder,项目名称:hifi,代码行数:15,代码来源:EntityServer.cpp

示例6: hasSpecialPacketToSend

// ModelServer will use the "special packets" to send list of recently deleted models
bool ModelServer::hasSpecialPacketToSend(const SharedNodePointer& node) {
    bool shouldSendDeletedModels = false;

    // check to see if any new models have been added since we last sent to this node...
    ModelNodeData* nodeData = static_cast<ModelNodeData*>(node->getLinkedData());
    if (nodeData) {
        quint64 deletedModelsSentAt = nodeData->getLastDeletedModelsSentAt();

        ModelTree* tree = static_cast<ModelTree*>(_tree);
        shouldSendDeletedModels = tree->hasModelsDeletedSince(deletedModelsSentAt);
    }

    return shouldSendDeletedModels;
}
开发者ID:MattiLahtinen,项目名称:hifi,代码行数:15,代码来源:ModelServer.cpp

示例7: timePingReply

void NodeList::timePingReply(ReceivedMessage& message, const SharedNodePointer& sendingNode) {
    PingType_t pingType;
    
    quint64 ourOriginalTime, othersReplyTime;
    
    message.seek(0);
    
    message.readPrimitive(&pingType);
    message.readPrimitive(&ourOriginalTime);
    message.readPrimitive(&othersReplyTime);

    quint64 now = usecTimestampNow();
    int pingTime = now - ourOriginalTime;
    int oneWayFlightTime = pingTime / 2; // half of the ping is our one way flight

    // The other node's expected time should be our original time plus the one way flight time
    // anything other than that is clock skew
    quint64 othersExpectedReply = ourOriginalTime + oneWayFlightTime;
    int clockSkew = othersReplyTime - othersExpectedReply;

    sendingNode->setPingMs(pingTime / 1000);
    sendingNode->updateClockSkewUsec(clockSkew);

    const bool wantDebug = false;

    if (wantDebug) {
        qCDebug(networking) << "PING_REPLY from node " << *sendingNode << "\n" <<
        "                     now: " << now << "\n" <<
        "                 ourTime: " << ourOriginalTime << "\n" <<
        "                pingTime: " << pingTime << "\n" <<
        "        oneWayFlightTime: " << oneWayFlightTime << "\n" <<
        "         othersReplyTime: " << othersReplyTime << "\n" <<
        "    othersExprectedReply: " << othersExpectedReply << "\n" <<
        "               clockSkew: " << clockSkew  << "\n" <<
        "       average clockSkew: " << sendingNode->getClockSkewUsec();
    }
}
开发者ID:JamesLinus,项目名称:hifi,代码行数:37,代码来源:NodeList.cpp

示例8: handleMuteEnvironmentPacket

void AudioMixer::handleMuteEnvironmentPacket(QSharedPointer<NLPacket> packet, SharedNodePointer sendingNode) {
    auto nodeList = DependencyManager::get<NodeList>();
    
    if (sendingNode->getCanAdjustLocks()) {
        auto newPacket = NLPacket::create(PacketType::MuteEnvironment, packet->getPayloadSize());
        // Copy payload
        newPacket->write(packet->getPayload(), packet->getPayloadSize());

        nodeList->eachNode([&](const SharedNodePointer& node){
            if (node->getType() == NodeType::Agent && node->getActiveSocket() &&
                node->getLinkedData() && node != sendingNode) {
                nodeList->sendPacket(std::move(newPacket), *node);
            }
        });
    }
}
开发者ID:GabrielPathfinder,项目名称:hifi,代码行数:16,代码来源:AudioMixer.cpp

示例9: updateNodeWithDataFromPacket

int LimitedNodeList::updateNodeWithDataFromPacket(const SharedNodePointer& matchingNode, const QByteArray &packet) {
    QMutexLocker locker(&matchingNode->getMutex());
    
    matchingNode->setLastHeardMicrostamp(usecTimestampNow());
    matchingNode->recordBytesReceived(packet.size());
    
    if (!matchingNode->getLinkedData() && linkedDataCreateCallback) {
        linkedDataCreateCallback(matchingNode.data());
    }
    
    QMutexLocker linkedDataLocker(&matchingNode->getLinkedData()->getMutex());
    
    return matchingNode->getLinkedData()->parseData(packet);
}
开发者ID:softwarekid,项目名称:hifi,代码行数:14,代码来源:LimitedNodeList.cpp

示例10: handleMessagesPacket

void MessagesClient::handleMessagesPacket(QSharedPointer<NLPacketList> packetList, SharedNodePointer senderNode) {
    QByteArray packetData = packetList->getMessage();
    QBuffer packet{ &packetData };
    packet.open(QIODevice::ReadOnly);

    quint16 channelLength;
    packet.read(reinterpret_cast<char*>(&channelLength), sizeof(channelLength));
    auto channelData = packet.read(channelLength);
    QString channel = QString::fromUtf8(channelData);

    quint16 messageLength;
    packet.read(reinterpret_cast<char*>(&messageLength), sizeof(messageLength));
    auto messageData = packet.read(messageLength);
    QString message = QString::fromUtf8(messageData);

    emit messageReceived(channel, message, senderNode->getUUID());
}
开发者ID:CaptainOculus,项目名称:hifi,代码行数:17,代码来源:MessagesClient.cpp

示例11: packetTypeForPacket

bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) {
    PacketType checkType = packetTypeForPacket(packet);
    int numPacketTypeBytes = numBytesArithmeticCodingFromBuffer(packet.data());
    
    if (packet[numPacketTypeBytes] != versionForPacketType(checkType)
        && checkType != PacketTypeStunResponse) {
        PacketType mismatchType = packetTypeForPacket(packet);
        
        static QMultiMap<QUuid, PacketType> versionDebugSuppressMap;
        
        QUuid senderUUID = uuidFromPacketHeader(packet);
        if (!versionDebugSuppressMap.contains(senderUUID, checkType)) {
            qDebug() << "Packet version mismatch on" << packetTypeForPacket(packet) << "- Sender"
            << uuidFromPacketHeader(packet) << "sent" << qPrintable(QString::number(packet[numPacketTypeBytes])) << "but"
            << qPrintable(QString::number(versionForPacketType(mismatchType))) << "expected.";
            
            versionDebugSuppressMap.insert(senderUUID, checkType);
        }
        
        return false;
    }
    
    if (!NON_VERIFIED_PACKETS.contains(checkType)) {
        // figure out which node this is from
        SharedNodePointer sendingNode = sendingNodeForPacket(packet);
        if (sendingNode) {
            // check if the md5 hash in the header matches the hash we would expect
            if (hashFromPacketHeader(packet) == hashForPacketAndConnectionUUID(packet, sendingNode->getConnectionSecret())) {
                return true;
            } else {
                qDebug() << "Packet hash mismatch on" << checkType << "- Sender"
                    << uuidFromPacketHeader(packet);
            }
        } else {
            static QString repeatedMessage
                = LogHandler::getInstance().addRepeatedMessageRegex("Packet of type \\d+ received from unknown node with UUID");
            
            qDebug() << "Packet of type" << checkType << "received from unknown node with UUID"
                << qPrintable(uuidStringWithoutCurlyBraces(uuidFromPacketHeader(packet)));
        }
    } else {
        return true;
    }
    
    return false;
}
开发者ID:softwarekid,项目名称:hifi,代码行数:46,代码来源:LimitedNodeList.cpp

示例12: safeServerName

OctreeSendThread::OctreeSendThread(const SharedAssignmentPointer& myAssignment, const SharedNodePointer& node) :
    _myAssignment(myAssignment),
    _myServer(static_cast<OctreeServer*>(myAssignment.data())),
    _node(node),
    _nodeUUID(node->getUUID()),
    _packetData(),
    _nodeMissingCount(0),
    _isShuttingDown(false)
{
    QString safeServerName("Octree");
    if (_myServer) {
        safeServerName = _myServer->getMyServerName();
    }
    qDebug() << qPrintable(safeServerName)  << "server [" << _myServer << "]: client connected "
                                            "- starting sending thread [" << this << "]";

    OctreeServer::clientConnected();
}
开发者ID:Adrianl3d,项目名称:hifi,代码行数:18,代码来源:OctreeSendThread.cpp

示例13: parsePerAvatarGainSet

void AudioMixerClientData::parsePerAvatarGainSet(ReceivedMessage& message, const SharedNodePointer& node) {
    QUuid uuid = node->getUUID();
    // parse the UUID from the packet
    QUuid avatarUuid = QUuid::fromRfc4122(message.readWithoutCopy(NUM_BYTES_RFC4122_UUID));
    uint8_t packedGain;
    message.readPrimitive(&packedGain);
    float gain = unpackFloatGainFromByte(packedGain);

    if (avatarUuid.isNull()) {
        // set the MASTER avatar gain
        setMasterAvatarGain(gain);
        qCDebug(audio) << "Setting MASTER avatar gain for " << uuid << " to " << gain;
    } else {
        // set the per-source avatar gain
        hrtfForStream(avatarUuid, QUuid()).setGainAdjustment(gain);
        qCDebug(audio) << "Setting avatar gain adjustment for hrtf[" << uuid << "][" << avatarUuid << "] to " << gain;
    }
}
开发者ID:SeijiEmery,项目名称:hifi,代码行数:18,代码来源:AudioMixerClientData.cpp

示例14: activateSocketFromNodeCommunication

void NodeList::activateSocketFromNodeCommunication(ReceivedMessage& message, const SharedNodePointer& sendingNode) {
    // deconstruct this ping packet to see if it is a public or local reply
    QDataStream packetStream(message.getMessage());

    quint8 pingType;
    packetStream >> pingType;

    // if this is a local or public ping then we can activate a socket
    // we do nothing with agnostic pings, those are simply for timing
    if (pingType == PingType::Local && sendingNode->getActiveSocket() != &sendingNode->getLocalSocket()) {
        sendingNode->activateLocalSocket();
    } else if (pingType == PingType::Public && !sendingNode->getActiveSocket()) {
        sendingNode->activatePublicSocket();
    } else if (pingType == PingType::Symmetric && !sendingNode->getActiveSocket()) {
        sendingNode->activateSymmetricSocket();
    }

    if (sendingNode->getType() == NodeType::AudioMixer) {
       flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetAudioMixerSocket);
    }
}
开发者ID:JamesLinus,项目名称:hifi,代码行数:21,代码来源:NodeList.cpp

示例15: handleEntityScriptCallMethodPacket

void EntityScriptServer::handleEntityScriptCallMethodPacket(QSharedPointer<ReceivedMessage> receivedMessage, SharedNodePointer senderNode) {

    if (_entitiesScriptEngine && _entityViewer.getTree() && !_shuttingDown) {
        auto entityID = QUuid::fromRfc4122(receivedMessage->read(NUM_BYTES_RFC4122_UUID));

        auto method = receivedMessage->readString();

        quint16 paramCount;
        receivedMessage->readPrimitive(&paramCount);

        QStringList params;
        for (int param = 0; param < paramCount; param++) {
            auto paramString = receivedMessage->readString();
            params << paramString;
        }

        _entitiesScriptEngine->callEntityScriptMethod(entityID, method, params, senderNode->getUUID());
    }
}
开发者ID:ZappoMan,项目名称:hifi,代码行数:19,代码来源:EntityScriptServer.cpp


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