diff options
Diffstat (limited to 'src/mad-core.cpp')
-rw-r--r-- | src/mad-core.cpp | 40 |
1 files changed, 7 insertions, 33 deletions
diff --git a/src/mad-core.cpp b/src/mad-core.cpp index 3ef7a80..ea0eded 100644 --- a/src/mad-core.cpp +++ b/src/mad-core.cpp @@ -17,44 +17,18 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Net/Listener.h" -#include "Net/ServerConnection.h" -#include "Net/IPAddress.h" -#include <iostream> +#include "Net/Connection.h" +#include "Core/ConnectionManager.h" -bool running = true; - -void receiveHandler(const Mad::Net::Connection*, const Mad::Net::Packet &packet) { - std::cout << "Received packet:" << std::endl; - std::cout << " Type: " << packet.getType() << std::endl; - std::cout << " Request ID: 0x" << std::hex << std::uppercase << packet.getRequestId() << std::dec << std::endl; - std::cout << " Length: " << packet.getLength() << std::endl; - - running = false; -} - int main() { Mad::Net::Connection::init(); - try { - Mad::Net::Listener listener(Mad::Net::IPAddress("0.0.0.0", 6666)); - - Mad::Net::ServerConnection *connection = 0; - - while((connection = listener.getConnection()) == 0) - usleep(100000); - - connection->signalReceive().connect(sigc::ptr_fun(receiveHandler)); - - while(running) - connection->sendReceive(); - - connection->disconnect(); - delete connection; - } - catch(Mad::Net::Exception &e) { - std::cerr << "Connection error: " << e.what() << std::endl; + Mad::Core::ConnectionManager connectionManager; + + while(true) { + connectionManager.run(); + connectionManager.wait(100000); } Mad::Net::Connection::deinit(); |