summaryrefslogtreecommitdiffstats
path: root/src/Client/InformationManager.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/Client/InformationManager.cpp
parent50d92f64547c5c06851976ceab5ed631ec93f647 (diff)
downloadmad-0b27c37fe95c6aced613d51a3624f8930a96ad3f.tar
mad-0b27c37fe95c6aced613d51a3624f8930a96ad3f.zip
RequestHandler-Interface ?berarbeitet
Diffstat (limited to 'src/Client/InformationManager.cpp')
-rw-r--r--src/Client/InformationManager.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp
index 78a0cf7..03a71c6 100644
--- a/src/Client/InformationManager.cpp
+++ b/src/Client/InformationManager.cpp
@@ -29,8 +29,8 @@ namespace Client {
InformationManager InformationManager::informationManager;
-void InformationManager::DaemonStateUpdateRequestHandler::handlePacket(const Common::XmlPacket &packet) {
- if(packet.getType() != "UpdateHostState") {
+void InformationManager::DaemonStateUpdateRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) {
+ if(packet->getType() != "UpdateHostState") {
Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
Common::XmlPacket ret;
@@ -48,9 +48,9 @@ void InformationManager::DaemonStateUpdateRequestHandler::handlePacket(const Com
{
boost::lock_guard<boost::mutex> lock(informationManager.mutex);
- std::map<std::string, Common::HostInfo>::iterator host = informationManager.daemons.find(packet["name"]);
+ std::map<std::string, Common::HostInfo>::iterator host = informationManager.daemons.find((*packet)["name"]);
if(host != informationManager.daemons.end())
- host->second.setState(packet["state"]);
+ host->second.setState((*packet)["state"]);
else
Common::Logger::log(Common::Logger::WARNING, "Received a state update for an unknown host.");
}
@@ -77,19 +77,22 @@ void InformationManager::updateDaemonList(Common::Connection *con) {
if(updating)
return;
- Common::RequestManager::get()->sendRequest0<Requests::DaemonListRequest>(con,
- boost::bind(&InformationManager::daemonListRequestFinished, this, _1));
+ updateRequest = boost::shared_ptr<Requests::DaemonListRequest>(new Requests::DaemonListRequest);
+ updateRequest->connectSignalFinished(boost::bind(&InformationManager::daemonListRequestFinished, this, _1, _2));
+
+ Common::RequestManager::get()->sendRequest(con, updateRequest);
updating = true;
}
-void InformationManager::daemonListRequestFinished(Common::Request &request) {
+void InformationManager::daemonListRequestFinished(boost::shared_ptr<const Common::XmlPacket> packet, Net::Exception error) {
boost::lock_guard<boost::mutex> lock(mutex);
- try {
- const Common::XmlPacket &packet = request.getResult();
-
- const Common::XmlPacket::Element &hostInfo = packet["hosts"];
+ if(!packet || error) {
+ Common::Logger::logf(Common::Logger::CRITICAL, "Host list request failed: %s", error.strerror().c_str());
+ }
+ else {
+ const Common::XmlPacket::Element &hostInfo = (*packet)["hosts"];
daemons.clear();
@@ -102,13 +105,8 @@ void InformationManager::daemonListRequestFinished(Common::Request &request) {
daemons.insert(std::make_pair(info.getName(), info));
}
}
- catch(Net::Exception &e) {
- Common::Logger::logf(Common::Logger::CRITICAL, "Host list request failed: %s", e.strerror().c_str());
- }
updating = false;
-
- updateCond.notify_all();
}
}