summaryrefslogtreecommitdiff
path: root/include/tgbot/net/HttpServer.h
diff options
context:
space:
mode:
authorOleg Morozenkov <omorozenkov@gmail.com>2015-08-12 13:43:02 +0300
committerOleg Morozenkov <omorozenkov@gmail.com>2015-08-12 13:43:02 +0300
commite3490d65bb824a9b4ee0fdc0872753fa295b1087 (patch)
tree0f61ecf6dd0e592c2390a8a93e3794dade2360f8 /include/tgbot/net/HttpServer.h
parent7b3fa406eb228a00ef9f053bd2177d53b61b1d3d (diff)
Fix some compiler errors with global header file
Diffstat (limited to 'include/tgbot/net/HttpServer.h')
-rw-r--r--include/tgbot/net/HttpServer.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/include/tgbot/net/HttpServer.h b/include/tgbot/net/HttpServer.h
index bac7382..888c0a8 100644
--- a/include/tgbot/net/HttpServer.h
+++ b/include/tgbot/net/HttpServer.h
@@ -38,22 +38,22 @@ namespace TgBot {
template<typename Protocol>
class HttpServer {
-private:
+protected:
class Connection;
public:
typedef std::function<std::string (const std::string&, const std::map<std::string, std::string>)> ServerHandler;
- HttpServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>>& acceptor, const ServerHandler& handler) : _acceptor(acceptor), _handler(handler) {
+ HttpServer(std::shared_ptr<boost::asio::basic_socket_acceptor<Protocol>> acceptor, const ServerHandler& handler) : _acceptor(acceptor), _handler(handler) {
}
/**
* Starts receiving new connections.
*/
void start() {
- std::shared_ptr<boost::asio::basic_stream_socket<Protocol>> socket(new boost::asio::basic_stream_socket<Protocol>(acceptor->get_io_service()));
- std::shared_ptr<Connection<Protocol>> connection(new Connection<Protocol>(socket, _handler));
- acceptor->async_accept(*connection->socket, [this, connection]() {
+ std::shared_ptr<boost::asio::basic_stream_socket<Protocol>> socket(new boost::asio::basic_stream_socket<Protocol>(_acceptor->get_io_service()));
+ std::shared_ptr<Connection> connection(new Connection(socket, _handler));
+ _acceptor->async_accept(*connection->socket, [this, connection]() {
connection->start();
start();
});
@@ -67,8 +67,7 @@ public:
_ioService.stop();
}
-private:
- template<typename Protocol>
+protected:
class Connection {
public:
@@ -89,7 +88,7 @@ private:
std::shared_ptr<boost::asio::basic_stream_socket<Protocol>> socket;
std::string data;
- private:
+ protected:
const ServerHandler _handler;
};