summaryrefslogtreecommitdiffstats
path: root/src/mad-core.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-06-26 16:39:25 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-06-26 16:39:25 +0200
commitea9fe3ef923000a7bfa4d7afc306669d5442e0fc (patch)
treefc549e40acbee781282478fc9c8e351507e99a9f /src/mad-core.cpp
parent91bdac7f768e538a2e25b04347b747b1902e3159 (diff)
downloadmad-ea9fe3ef923000a7bfa4d7afc306669d5442e0fc.tar
mad-ea9fe3ef923000a7bfa4d7afc306669d5442e0fc.zip
ConnectionManager f?r den Kern hinzugef?gt
Diffstat (limited to 'src/mad-core.cpp')
-rw-r--r--src/mad-core.cpp40
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();