本文整理汇总了C++中PacketPtr::complete方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketPtr::complete方法的具体用法?C++ PacketPtr::complete怎么用?C++ PacketPtr::complete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketPtr
的用法示例。
在下文中一共展示了PacketPtr::complete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _complete_packet
void RealmConnection::_complete_packet(PacketPtr packet_ptr)
{
UT_DEBUGMSG(("RealmConnection::_complete_packet()\n"));
int bytes_needed = packet_ptr->complete(m_buf.data(), m_buf.size());
switch (bytes_needed)
{
case -1:
UT_DEBUGMSG(("Error determining packet (type: 0x%x) completion state!\n", packet_ptr->type()));
return;
case 0:
{
UT_DEBUGMSG(("Read full packet\n"));
UT_return_if_fail(packet_ptr->parse(m_buf.data(), m_buf.size()) != -1);
m_packet_queue.push(packet_ptr);
_receive();
}
break;
default:
UT_DEBUGMSG(("Need more data (%d bytes) for this packet...\n", bytes_needed));
// read the needed number of bytes
char* ptr = m_buf.prepare(bytes_needed);
asio::async_read(m_socket, asio::buffer(ptr, bytes_needed),
boost::bind(&RealmConnection::_complete, shared_from_this(),
asio::placeholders::error, asio::placeholders::bytes_transferred, packet_ptr)
);
break;
}
}