示例#1
0
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
0
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;
}