// 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 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)); } void write_w_close(const std::vector& data); void write_w_response(const std::vector& data); void write_wo_response(const std::vector& data); private: 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& data); ssl_socket socket_; char *snd_data, *recv_data; }; #endif