本文整理汇总了C++中ObPacket::get_data_length方法的典型用法代码示例。如果您正苦于以下问题:C++ ObPacket::get_data_length方法的具体用法?C++ ObPacket::get_data_length怎么用?C++ ObPacket::get_data_length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObPacket
的用法示例。
在下文中一共展示了ObPacket::get_data_length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send_request
int ObClientManager::send_request(const ObServer& server, const int32_t pcode, const int32_t version,
const int64_t timeout, ObDataBuffer& in_buffer, ObDataBuffer& out_buffer, int64_t& session_id) const
{
int rc = OB_SUCCESS;
ObPacket* response = NULL;
rc = do_send_request(server, pcode, version, timeout, in_buffer, response);
// deserialize response packet to out_buffer
if (OB_SUCCESS == rc && NULL != response)
{
session_id = response->get_session_id() ; // TODO
// copy response's inner_buffer to out_buffer.
int64_t data_length = response->get_data_length();
ObDataBuffer* response_buffer = response->get_buffer();
if (out_buffer.get_remain() < data_length)
{
TBSYS_LOG(ERROR, "insufficient memory in out_buffer, remain:%ld, length=%ld",
out_buffer.get_remain(), data_length);
rc = OB_ERROR;
}
else
{
memcpy(out_buffer.get_data() + out_buffer.get_position(),
response_buffer->get_data() + response_buffer->get_position(),
data_length);
out_buffer.get_position() += data_length;
}
}
return rc;
}
示例2: get_next
int ObClientManager::get_next(const ObServer& server, const int64_t session_id,
const int64_t timeout, ObDataBuffer& in_buffer, ObDataBuffer& out_buffer) const
{
int rc = OB_SUCCESS;
ObPacket* response = NULL;
//rc = send_request(server, pcode, version, timeout, in_buffer, response);
ObPacket* packet = new (std::nothrow) ObPacket();
if (NULL == packet)
{
rc = OB_ALLOCATE_MEMORY_FAILED;
}
else
{
packet->set_packet_code(OB_SESSION_NEXT_REQUEST);
packet->setChannelId(0);
packet->set_api_version(0);
packet->set_data(in_buffer);
packet->set_source_timeout(timeout);
packet->set_session_id(session_id); //TODO
}
if (OB_SUCCESS == rc)
{
rc = packet->serialize();
if (OB_SUCCESS != rc)
TBSYS_LOG(WARN, "packet serialize error, code=%d", packet->get_packet_code());
}
// serialize failed
if (OB_SUCCESS != rc && NULL != packet)
{
packet->free();
}
if (OB_SUCCESS == rc)
{
rc = do_send_packet(server, packet, timeout, response);
}
// deserialize response packet to out_buffer
if (OB_SUCCESS == rc && NULL != response)
{
// copy response's inner_buffer to out_buffer.
int64_t data_length = response->get_data_length();
ObDataBuffer* response_buffer = response->get_buffer();
if (out_buffer.get_remain() < data_length)
{
TBSYS_LOG(ERROR, "insufficient memory in out_buffer, remain:%ld, length=%ld",
out_buffer.get_remain(), data_length);
rc = OB_ERROR;
}
else
{
memcpy(out_buffer.get_data() + out_buffer.get_position(),
response_buffer->get_data() + response_buffer->get_position(),
data_length);
out_buffer.get_position() += data_length;
}
}
return rc;
}