From 197582bcf7458cafb571fde7d37ef4415d0d8f4a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 3 Sep 2009 23:43:56 +0200 Subject: Renamed mad -> madd There are too many programs called mad... --- src/madd.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/madd.cpp (limited to 'src/madd.cpp') diff --git a/src/madd.cpp b/src/madd.cpp new file mode 100644 index 0000000..0062d01 --- /dev/null +++ b/src/madd.cpp @@ -0,0 +1,84 @@ +/* + * mad.cpp + * + * Copyright (C) 2008 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see . + */ + +#include "Core/ConfigManager.h" +#include "Core/LogManager.h" + +#include "Common/ModuleManager.h" +#include "Common/RequestManager.h" +#include "Common/ClientConnection.h" +#include "Common/Requests/IdentifyRequest.h" +#include "Common/RequestHandlers/FSInfoRequestHandler.h" +#include "Common/RequestHandlers/StatusRequestHandler.h" + +#include "Daemon/Application.h" +#include "Daemon/Backends/NetworkLogger.h" +#include "Daemon/RequestHandlers/CommandRequestHandler.h" + +using namespace Mad; + + +int main() { + Daemon::Application application; + + application.getConfigManager()->loadFile("madd.conf"); + application.getConfigManager()->finish(); + + application.getRequestManager()->registerPacketType("Command"); + application.getRequestManager()->registerPacketType("FSInfo"); + application.getRequestManager()->registerPacketType("GetStatus"); + + Common::ClientConnection *connection = new Common::ClientConnection(&application); + + try { + application.getRequestManager()->registerConnection(connection); + + connection->connect(boost::asio::ip::tcp::endpoint( + boost::asio::ip::address_v4::from_string("127.0.0.1"), 6666)); + + connection->waitWhileConnecting(); + + boost::shared_ptr networkLogger(new Daemon::Backends::NetworkLogger(&application, connection)); + application.getLogManager()->registerLogger(networkLogger); + + { + boost::shared_ptr request(new Common::Requests::IdentifyRequest(&application, "test")); + application.getRequestManager()->sendRequest(connection, request); + request->wait(); + } + application.log("Identified."); + + connection->waitWhileConnected(); + + application.getLogManager()->unregisterLogger(networkLogger); + + application.getRequestManager()->unregisterConnection(connection); + } + catch(Core::Exception &e) { + application.logf(Core::Logger::LOG_CRITICAL, "Connection error: %s", e.what()); + } + + delete connection; + + application.getRequestManager()->unregisterPacketType("Command"); + application.getRequestManager()->unregisterPacketType("FSInfo"); + application.getRequestManager()->unregisterPacketType("GetStatus"); + + return 0; +} -- cgit v1.2.3