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
46
47
48
49
50
51
52
53
|
// Copyright © 2013 sss
//.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SESSION_H
#define SESSION_H
using boost::asio::ip::tcp;
typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;
class session
{
public:
session(boost::asio::io_service& io_service, boost::asio::ssl::context& context) : socket_(io_service, context)
{}
ssl_socket::lowest_layer_type& socket()
{
return socket_.lowest_layer();
}
void handle_handshake(const boost::system::error_code& error);
void start()
{
socket_.async_handshake(boost::asio::ssl::stream_base::server, boost::bind(&session::handle_handshake, this, boost::asio::placeholders::error));
}
private:
void write_w_close(const std::vector<unsigned char>& data);
void write_w_response(const std::vector<unsigned char>& data);
void write_wo_response(const std::vector<unsigned char>& data);
void handle_read(const boost::system::error_code& error, size_t bytes_transferred);
void handle_write(const boost::system::error_code& error, size_t bytes_transferred);
void handle_write_close(const boost::system::error_code& error, size_t bytes_transferred);
void handle_operation(const boost::system::error_code& error, size_t bytes_transferred);
void pack_buffer(const std::vector<unsigned char>& data);
ssl_socket socket_;
char *snd_data, *recv_data;
};
#endif
|