1 #ifndef BLANK_NET_CHUNKTRANSMITTER_HPP_
2 #define BLANK_NET_CHUNKTRANSMITTER_HPP_
12 class ClientConnection;
14 class ChunkTransmitter {
17 explicit ChunkTransmitter(ClientConnection &);
20 /// Returns true if not transmitting or waiting on acks, so
21 /// the next chunk may be queued without schmutzing up anything.
22 bool Idle() const noexcept;
24 /// Returns true if a transmission is still going on,
25 /// meaning there's at least one packet that needs to
27 bool Transmitting() const noexcept;
28 /// Send the next packet of the current chunk (if any).
31 /// Returns true if there's one or more packets which
32 /// still have to be ack'd by the remote.
33 bool Waiting() const noexcept;
34 /// Mark packet with given sequence number as ack'd.
35 /// If all packets for the current chunk have been ack'd
36 /// the transmission is considered complete.
37 void Ack(std::uint16_t);
38 /// Mark packet with given sequence number as lost.
39 /// Its part of the chunk data should be resent.
40 void Nack(std::uint16_t);
42 /// Cancel the current transmission.
44 /// Start transmitting given chunk.
45 /// If there's a chunk already in transmission it will be
51 void SendData(std::size_t);
55 ClientConnection &conn;
57 std::size_t buffer_size;
58 std::unique_ptr<std::uint8_t[]> buffer;
59 std::size_t buffer_len;
60 std::size_t packet_len;
62 std::size_t num_packets;
64 std::vector<int> data_packets;
66 std::uint32_t trans_id;