diff options
Diffstat (limited to 'server/session.h')
-rw-r--r-- | server/session.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/server/session.h b/server/session.h new file mode 100644 index 0000000..6e3bb1b --- /dev/null +++ b/server/session.h @@ -0,0 +1,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 |