本文整理汇总了C++中DataObjectRef::isThisNodeDescription方法的典型用法代码示例。如果您正苦于以下问题:C++ DataObjectRef::isThisNodeDescription方法的具体用法?C++ DataObjectRef::isThisNodeDescription怎么用?C++ DataObjectRef::isThisNodeDescription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectRef
的用法示例。
在下文中一共展示了DataObjectRef::isThisNodeDescription方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSendDataObject
/*
On send events, the security manager
*/
void SecurityManager::onSendDataObject(Event *e)
{
if (!e || !e->hasData())
return;
DataObjectRef dObj = e->getDataObject();
if (dObj->isThisNodeDescription()) {
// This is our node description. Piggy-back our certificate.
if (myCert) {
Metadata *m;
m = dObj->getMetadata()->getMetadata("Security");
if (m) {
HAGGLE_ERR("Node description already has a Security tag!\n");
} else {
m = dObj->getMetadata()->addMetadata("Security");
if (m) {
m->addMetadata(myCert->toMetadata());
}
}
}
}
// In most cases the data object is already signed here (e.g., if it is generated by a local
// application, or was received from another node). The only reason to check if we should
// sign the data object here, is if a data object was generated internally by Haggle -- in
// which case the data object might not have a signature (e.g., the data object is a node
// description).
InterfaceRef iface = dObj->getRemoteInterface();
if (dObj->shouldSign() && !(iface && iface->getType() == Interface::TYPE_APPLICATION_PORT)) {
// FIXME: data objects should really be signed in the SecurityHelper thread since
// it is a potentially CPU intensive operation. But it is currently not possible
// to ensure that the signing operation has finished in the helper thread before
// the data object is actually sent on the wire by the protocol manager.
// To handle this situation, we probably need to add a new public event for
// security related operations, after which the security manager generates the
// real send event.
if (helper->signDataObject(dObj, privKey)) {
HAGGLE_DBG("Successfully signed data object %s\n", dObj->getIdStr());
} else {
HAGGLE_DBG("Signing of data object %s failed!\n", dObj->getIdStr());
}
}
}