From 376b88ec09ef8cf71dd823467406c58204485fcc Mon Sep 17 00:00:00 2001 From: Oleg Morozenkov Date: Tue, 11 Aug 2015 22:13:23 +0300 Subject: Fixed compiler's errors in TgTypeParser + fixed indentation + some other fixes --- include/tgbot/net/HttpServer.h | 106 ++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 'include/tgbot/net/HttpServer.h') diff --git a/include/tgbot/net/HttpServer.h b/include/tgbot/net/HttpServer.h index 0a66900..bac7382 100644 --- a/include/tgbot/net/HttpServer.h +++ b/include/tgbot/net/HttpServer.h @@ -39,63 +39,63 @@ template class HttpServer { private: - class Connection; + class Connection; public: - typedef std::function)> ServerHandler; - - HttpServer(std::shared_ptr>& acceptor, const ServerHandler& handler) : _acceptor(acceptor), _handler(handler) { - } - - /** - * Starts receiving new connections. - */ - void start() { - std::shared_ptr> socket(new boost::asio::basic_stream_socket(acceptor->get_io_service())); - std::shared_ptr> connection(new Connection(socket, _handler)); - acceptor->async_accept(*connection->socket, [this, connection]() { - connection->start(); - start(); - }); - _ioService.run(); - } - - /** - * Stops receiving new connections. - */ - void stop() { - _ioService.stop(); - } + typedef std::function)> ServerHandler; + + HttpServer(std::shared_ptr>& acceptor, const ServerHandler& handler) : _acceptor(acceptor), _handler(handler) { + } + + /** + * Starts receiving new connections. + */ + void start() { + std::shared_ptr> socket(new boost::asio::basic_stream_socket(acceptor->get_io_service())); + std::shared_ptr> connection(new Connection(socket, _handler)); + acceptor->async_accept(*connection->socket, [this, connection]() { + connection->start(); + start(); + }); + _ioService.run(); + } + + /** + * Stops receiving new connections. + */ + void stop() { + _ioService.stop(); + } private: - template - class Connection { - - public: - Connection(std::shared_ptr>& socket, const ServerHandler& handler) : socket(socket), _handler(handler) { - boost::asio::socket_base::keep_alive option(true); - socket.set_option(option); - } - - void start() { - data.reserve(10240); - socket->async_receive(data, [this]() { - std::map headers; - std::string body = HttpParser::parseResponse(data, headers); - socket->async_send(_handler(body, headers)); - }); - } - - std::shared_ptr> socket; - std::string data; - - private: - const ServerHandler _handler; - }; - - boost::asio::io_service _ioService; - std::shared_ptr> _acceptor; - const ServerHandler _handler; + template + class Connection { + + public: + Connection(std::shared_ptr>& socket, const ServerHandler& handler) : socket(socket), _handler(handler) { + boost::asio::socket_base::keep_alive option(true); + socket.set_option(option); + } + + void start() { + data.reserve(10240); + socket->async_receive(data, [this]() { + std::map headers; + std::string body = HttpParser::parseResponse(data, headers); + socket->async_send(_handler(body, headers)); + }); + } + + std::shared_ptr> socket; + std::string data; + + private: + const ServerHandler _handler; + }; + + boost::asio::io_service _ioService; + std::shared_ptr> _acceptor; + const ServerHandler _handler; }; } -- cgit v1.2.3