本文整理汇总了C++中NetworkPacket::ParseFromArray方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkPacket::ParseFromArray方法的具体用法?C++ NetworkPacket::ParseFromArray怎么用?C++ NetworkPacket::ParseFromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkPacket
的用法示例。
在下文中一共展示了NetworkPacket::ParseFromArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notify_received
void UdpMulticastChannel::notify_received(char* data, size_t sz,boost::asio::ip::udp::endpoint sender_endpoint)
{
std::vector<unsigned>* lost;
NetworkPacket* packet = new NetworkPacket;
if (packet->ParseFromArray(data,sz))
{
lost = incoming->add_packet(packet);
if (lost->size() > 0 )
{
send_nack(packet,sender_endpoint,lost);
}
}
//std::cout << "Received: " << sz << " bytes " << std::endl;
receive_from_network();
}
示例2: read_from_network
void UdpMulticastChannel::read_from_network()
{
boost::asio::ip::udp::endpoint sender_endpoint;
unsigned int sz = MAX_PACKET_SIZE;
std::vector<unsigned>* lost;
char* data = new char[sz];
receiver->sync_receive(data,sz,&sender_endpoint);
NetworkPacket* packet = new NetworkPacket;
if (packet->ParseFromArray(data,sz))
{
lost = incoming->add_packet(packet);
if (lost->size() > 0 )
{
//send message to endpoint to resent data
//sender->sync_send()
}
}
delete data;
}