-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.h
More file actions
45 lines (37 loc) · 1.2 KB
/
Client.h
File metadata and controls
45 lines (37 loc) · 1.2 KB
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
36
37
38
39
40
41
42
43
44
45
#ifndef CLIENT_H_
#define CLIENT_H_
#include "Packet.h"
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <iostream>
#include <vector>
#include <deque>
#include <boost/serialization/vector.hpp>
#include <boost/thread.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
namespace securityClient {
using boost::asio::ip::tcp;
typedef boost::shared_ptr<std::vector<boost::asio::const_buffer> > PacketBufferPtr;
class Client {
public:
Client(boost::asio::io_service& io_service, const std::string& host,
const std::string& service);
virtual ~Client(){};
void send(const Packet &packet);
private:
Packet recv_packet_;
std::deque<PacketBufferPtr> send_vector_;
boost::asio::io_service &io_service_;
tcp::socket socket_;
boost::shared_ptr<boost::thread> receive_thread_;
void handle_connect(const boost::system::error_code& e);
void handle_read(const boost::system::error_code& e){};
void handle_write(const boost::system::error_code& error);
void handle_command(const Packet packet){};
void do_write(PacketBufferPtr packet);
void handle_receive_packet();
void handle_receive_action(Packet packer);
};
} /* namespace securityClient */
#endif /* CLIENT_H_ */