本文整理汇总了C++中message::header_code方法的典型用法代码示例。如果您正苦于以下问题:C++ message::header_code方法的具体用法?C++ message::header_code怎么用?C++ message::header_code使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message
的用法示例。
在下文中一共展示了message::header_code方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_response
void find_operation::on_response(message & msg, const bool & done)
{
if (state() == state_started)
{
/**
* Inform base class.
*/
operation::on_response(msg, done);
/**
* Check if we've got a response.
*/
if (msg.header_code() == protocol::message_code_ack)
{
/**
* Increment the number of find responses.
*/
find_responses_++;
log_debug(
"Find operation " << m_transaction_id << " find_responses = " <<
find_responses_ << ", ep = " << msg.source_endpoint()
);
/**
* If the number of responses is acceptable call stop.
*/
if (find_responses_ >= max_results_)
{
auto elapsed = std::chrono::duration_cast<
std::chrono::milliseconds
>(std::chrono::steady_clock::now() - uptime_).count();
log_debug(
"Find operation is stopping, probed = " <<
probed_.size() << ", find_responses_ = " <<
find_responses_ << ", elapsed = " << elapsed << "."
);
/**
* Stop
*/
stop();
}
}
}
}
示例2: on_response
void store_operation::on_response(message & msg, const bool & done)
{
if (state() == state_started)
{
/**
* Inform base class.
*/
operation::on_response(msg, done);
if (msg.header_code() == protocol::message_code_ack)
{
/**
* Increment the number of store responses.
*/
store_responses_++;
log_debug(
"store_responses_ = " << store_responses_ << ", ep = " <<
msg.source_endpoint()
);
/**
* If we've stored at N storage nodes call stop.
*/
if (
store_responses_ >=
(m_query.pairs_public().size() *
constants::snodes_per_keyword) || store_responses_ >= 128
)
{
log_debug(
"Store operation probed " << probed_.size() <<
" storage nodes, value stored at " << store_responses_ <<
" storage nodes, stopping."
);
/**
* Stop
*/
stop();
}
}
}
}