-
Notifications
You must be signed in to change notification settings - Fork 0
/
Connection.hpp
35 lines (28 loc) · 979 Bytes
/
Connection.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef CONNECTION_HPP
#define CONNECTION_HPP
#include "AEvent/AEventAbstract.hpp"
#include "Proto.hpp"
#include "Utils/Files.hpp"
class Connection: public AEventAbstract
{
public:
explicit Connection(AEvChildConf && config, asio::ip::tcp::socket && _soc);
private:
asio::ip::tcp::socket _socket;
ProtoHeader _header;
std::shared_ptr<hfile::FileGuard> _target_file;
const size_t _data_buffer_lenth {1024};
uint64_t _bytes_received {0};
unsigned _prev_percent {0};
virtual void _ev_begin() override;
virtual void _ev_finish() override;
virtual void _ev_stop() override;
virtual void _ev_timeout() override;
virtual void _ev_child_callback(AEvPtrBase child_ptr, AEvExitSignal & _ret) override;
void _read_header();
void _read_filename();
void _create_file(std::shared_ptr<std::string> fname_);
void _read_data();
void _write_file_part(std::shared_ptr<std::vector<char>> data_);
};
#endif // CONNECTION_HPP