当前位置: 首页>>代码示例>>C++>>正文


C++ NetworkPacket::ParseFromArray方法代码示例

本文整理汇总了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();
}
开发者ID:vagvaz,项目名称:Narukom,代码行数:15,代码来源:udp_multicast_channel.cpp

示例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;
}
开发者ID:vagvaz,项目名称:Narukom,代码行数:20,代码来源:udp_multicast_channel.cpp


注:本文中的NetworkPacket::ParseFromArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。