diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-08-18 15:58:17 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-08-18 15:58:17 +0200 |
commit | db5ad2e09a6b38e841463dbe7eb076492b62c948 (patch) | |
tree | 5907f6416e35cbd25432a5f1f6dc9664d36aa73c /src/Net/Listener.cpp | |
parent | 5da7b0847bac2a5abec95b9ac1701b74baae8964 (diff) | |
download | mad-db5ad2e09a6b38e841463dbe7eb076492b62c948.tar mad-db5ad2e09a6b38e841463dbe7eb076492b62c948.zip |
Mad funktioniert jetzt unter Windows
Diffstat (limited to 'src/Net/Listener.cpp')
-rw-r--r-- | src/Net/Listener.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp index 89ea399..6187a1e 100644 --- a/src/Net/Listener.cpp +++ b/src/Net/Listener.cpp @@ -26,6 +26,20 @@ namespace Mad { namespace Net { +void Listener::accept() { + boost::shared_ptr<Connection> con(new Connection(application)); + + con->context.set_options(boost::asio::ssl::context::default_workarounds + | boost::asio::ssl::context::no_sslv2 + | boost::asio::ssl::context::single_dh_use); + con->context.use_certificate_chain_file(x905CertFile); + con->context.use_private_key_file(x905KeyFile, boost::asio::ssl::context::pem); + + con->_initSocket(); + + acceptor.async_accept(con->socket->lowest_layer(), boost::bind(&Listener::handleAccept, this, boost::asio::placeholders::error, con)); +} + void Listener::handleAccept(const boost::system::error_code &error, boost::shared_ptr<Connection> con) { if(error) return; @@ -42,11 +56,10 @@ void Listener::handleAccept(const boost::system::error_code &error, boost::share connections.insert(std::make_pair(con, std::make_pair(con1, con2))); - con->socket.async_handshake(boost::asio::ssl::stream_base::server, boost::bind(&Connection::handleHandshake, con, boost::asio::placeholders::error)); + con->socket->async_handshake(boost::asio::ssl::stream_base::server, boost::bind(&Connection::handleHandshake, con, boost::asio::placeholders::error)); } - con.reset(new Connection(application, sslContext)); - acceptor.async_accept(con->socket.lowest_layer(), boost::bind(&Listener::handleAccept, this, boost::asio::placeholders::error, con)); + accept(); } void Listener::handleConnect(boost::shared_ptr<Connection> con) { @@ -76,19 +89,8 @@ void Listener::handleDisconnect(boost::shared_ptr<Connection> con) { Listener::Listener(Core::Application *application0, const std::string &x905CertFile0, const std::string &x905KeyFile0, const boost::asio::ip::tcp::endpoint &address0) throw(Core::Exception) : application(application0), x905CertFile(x905CertFile0), x905KeyFile(x905KeyFile0), address(address0), -acceptor(application->getIOService(), address), sslContext(application->getIOService(), boost::asio::ssl::context::sslv23), -signal(application) -{ - sslContext.set_options(boost::asio::ssl::context::default_workarounds - | boost::asio::ssl::context::no_sslv2 - | boost::asio::ssl::context::single_dh_use); - sslContext.use_certificate_chain_file(x905CertFile0); - sslContext.use_private_key_file(x905KeyFile0, boost::asio::ssl::context::pem); - - - - boost::shared_ptr<Connection> con(new Connection(application, sslContext)); - acceptor.async_accept(con->socket.lowest_layer(), boost::bind(&Listener::handleAccept, this, boost::asio::placeholders::error, con)); +acceptor(application->getIOService(), address), signal(application) { + accept(); } Listener::~Listener() { |