summaryrefslogtreecommitdiffstats
path: root/src/madc.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-06-04 22:23:07 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-06-04 22:23:07 +0200
commit0b27c37fe95c6aced613d51a3624f8930a96ad3f (patch)
tree5cb92568f70fe9789e99633ec71048389efb7fa4 /src/madc.cpp
parent50d92f64547c5c06851976ceab5ed631ec93f647 (diff)
downloadmad-0b27c37fe95c6aced613d51a3624f8930a96ad3f.tar
mad-0b27c37fe95c6aced613d51a3624f8930a96ad3f.zip
RequestHandler-Interface ?berarbeitet
Diffstat (limited to 'src/madc.cpp')
-rw-r--r--src/madc.cpp30
1 files changed, 4 insertions, 26 deletions
diff --git a/src/madc.cpp b/src/madc.cpp
index 40bd51c..64078c8 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -37,21 +37,10 @@
using namespace Mad;
-static bool commandRunning = false;
-static boost::mutex commandMutex;
-static boost::condition_variable commandNotify;
-
static void usage(const std::string &cmd) {
std::cerr << "Usage: " << cmd << " address" << std::endl;
}
-static void commandFinished() {
- boost::lock_guard<boost::mutex> lock(commandMutex);
- commandRunning = false;
-
- commandNotify.notify_one();
-}
-
int main(int argc, char *argv[]) {
if(argc != 2) {
usage(argv[0]);
@@ -75,12 +64,9 @@ int main(int argc, char *argv[]) {
Common::RequestManager::get()->registerConnection(connection);
{
- boost::unique_lock<boost::mutex> lock(commandMutex);
- commandRunning = true;
- Common::RequestManager::get()->sendRequest0<Common::Requests::IdentifyRequest>(connection, boost::bind(&commandFinished));
- while(commandRunning) {
- commandNotify.wait(lock);
- }
+ boost::shared_ptr<Common::Requests::IdentifyRequest> request(new Common::Requests::IdentifyRequest);
+ Common::RequestManager::get()->sendRequest(connection, request);
+ request->wait();
}
std::cerr << " connected." << std::endl;
@@ -92,13 +78,10 @@ int main(int argc, char *argv[]) {
std::cerr << " done." << std::endl << std::endl;
Client::CommandParser::get()->setConnection(connection);
- Client::CommandManager::get()->connectSignalFinished(&commandFinished);
- while(connection->isConnected() && !Client::CommandManager::get()->willDisconnect()) {
+ while(connection->isConnected() && !Client::CommandParser::get()->willDisconnect()) {
char *cmd = readline("mad> ");
- boost::unique_lock<boost::mutex> lock(commandMutex);
-
if(!cmd) {
Client::CommandParser::get()->requestDisconnect();
}
@@ -107,11 +90,6 @@ int main(int argc, char *argv[]) {
add_history(cmd);
}
else continue;
-
- commandRunning = Client::CommandManager::get()->requestsActive();
-
- while(commandRunning)
- commandNotify.wait(lock);
}
connection->waitWhileConnected();