本文整理汇总了C++中meta_message_ptr::scope方法的典型用法代码示例。如果您正苦于以下问题:C++ meta_message_ptr::scope方法的具体用法?C++ meta_message_ptr::scope怎么用?C++ meta_message_ptr::scope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meta_message_ptr
的用法示例。
在下文中一共展示了meta_message_ptr::scope方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sac_process_message
/**
* Check if there's a handler for this message and call it, else
* discard message.
*
* @param in The input message.
* @param out The output message.
*/
bool sac_process_message(meta_message_ptr& in, meta_message_ptr& out)
{
// discard messages that this MIHF broadcasted to itself
// discard messages that are not destined to this MIHF or if
// multicast messages are not supported
if(in->source() == mihfid) {
ODTONE_LOG(1, "(sac) Discarding message! Reason: ",
"message was broadcasted to itself");
return false;
}
if(!utils::this_mihf_is_destination(in) && !utils::is_multicast(in)) {
ODTONE_LOG(1, "(sac) Discarding message! Reason: ",
"this is not the message destination");
return false;
}
/** __no__ authentication at this point */
uint mid = in->mid();
//
// no thread safety because insertion should __only__ be made
// on MIHF initialization
//
std::map<uint, handler_t>::iterator it;
it = _callbacks.find(mid);
if(it != _callbacks.end()) {
handler_t process_message = it->second;
bool rsp;
try {
rsp = process_message(in, out);
} catch(mih::bad_tlv) {
ODTONE_LOG(1, "Discarding malformed message.");
return false;
}
// set ip and port of response message
out->ip(in->ip());
out->scope(in->scope());
out->port(in->port());
// response message must have the same tid
out->tid(in->tid());
return rsp;
} else {
ODTONE_LOG(1, "(sac) (warning) message with mid: ", mid,
" unknown, discarding.");
}
return false;
}