本文整理汇总了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);
}
示例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;
}