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


C++ NLPacket::payloadHashWithConnectionUUID方法代码示例

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


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

示例1: writePacket

qint64 LimitedNodeList::writePacket(const NLPacket& packet, const HifiSockAddr& destinationSockAddr,
                                    const QUuid& connectionSecret) {
    if (!NON_SOURCED_PACKETS.contains(packet.getType())) {
        const_cast<NLPacket&>(packet).writeSourceID(getSessionUUID());
    }
    
    if (!connectionSecret.isNull()
        && !NON_SOURCED_PACKETS.contains(packet.getType())
        && !NON_VERIFIED_PACKETS.contains(packet.getType())) {
        const_cast<NLPacket&>(packet).writeVerificationHash(packet.payloadHashWithConnectionUUID(connectionSecret));
    }

    emit dataSent(NodeType::Unassigned, packet.getDataSize());
    
    return writeDatagram(QByteArray::fromRawData(packet.getData(), packet.getDataSize()), destinationSockAddr);
}
开发者ID:rabedik,项目名称:hifi,代码行数:16,代码来源:LimitedNodeList.cpp

示例2: packetSourceAndHashMatch

bool LimitedNodeList::packetSourceAndHashMatch(const NLPacket& packet, SharedNodePointer& matchingNode) {
    
    if (NON_SOURCED_PACKETS.contains(packet.getType())) {
        return true;
    } else {
        
        // figure out which node this is from
        matchingNode = nodeWithUUID(packet.getSourceID());
        
        if (matchingNode) {
            if (!NON_VERIFIED_PACKETS.contains(packet.getType())) {
                // check if the md5 hash in the header matches the hash we would expect
                if (packet.getVerificationHash() != packet.payloadHashWithConnectionUUID(matchingNode->getConnectionSecret())) {
                    static QMultiMap<QUuid, PacketType::Value> hashDebugSuppressMap;
                    
                    const QUuid& senderID = packet.getSourceID();

                    if (!hashDebugSuppressMap.contains(senderID, packet.getType())) {
                        qCDebug(networking) << "Packet hash mismatch on" << packet.getType() << "- Sender" << senderID;

                        hashDebugSuppressMap.insert(senderID, packet.getType());
                    }

                    return false;
                }
            }
            
            return true;
            
        } else {
            static QString repeatedMessage
                = LogHandler::getInstance().addRepeatedMessageRegex("Packet of type \\d+ \\([\\sa-zA-Z]+\\) received from unknown node with UUID");

            qCDebug(networking) << "Packet of type" << packet.getType() << "(" << qPrintable(nameForPacketType(packet.getType())) << ")"
                << "received from unknown node with UUID" << qPrintable(uuidStringWithoutCurlyBraces(packet.getSourceID()));
        }
    }

    return false;
}
开发者ID:rabedik,项目名称:hifi,代码行数:40,代码来源:LimitedNodeList.cpp


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