00001 #include "MessageExecutor.h" 00002 00003 MessageExecutor::MessageExecutor() { 00004 } 00005 00006 void MessageExecutor::executeMessage(Message * m) { 00007 TreeNode * node = m->getTree(); 00008 try { 00009 if (node->existChild("request")) { 00010 string value = node->getChild("request")->getValue(); 00011 if (value == "update") { 00012 ConnectorSingleton::getConnector()->sendUpdate(); 00013 } 00014 } else if (node->existChild("patch")) { 00015 string from = node->getChild("patch")->getChild("from")->getValue(); 00016 string to = node->getChild("patch")->getChild("to")->getValue(); 00017 int fhFrom = atoi(from.c_str()); 00018 int fhTo = atoi(to.c_str()); 00019 ConnectorSingleton::getConnector()->patch(fhFrom,fhTo); 00020 } else if (node->existChild("unPatch")) { 00021 string from = node->getChild("unPatch")->getChild("from")->getValue(); 00022 string to = node->getChild("unPatch")->getChild("to")->getValue(); 00023 int fhFrom = atoi(from.c_str()); 00024 int fhTo = atoi(to.c_str()); 00025 ConnectorSingleton::getConnector()->unPatch(fhFrom,fhTo); 00026 } else if (node->existChild("disconnect")) { 00027 string con = node->getChild("disconnect")->getChild("connection")->getValue(); 00028 ConnectorSingleton::getConnector()->disconnect(atoi(con.c_str())); 00029 } else if (node->existChild("changedSince")) { 00030 ConnectorSingleton::getConnector()->lastChange(); 00031 } else if (node->existChild("shutdown")) { 00032 ConnectorSingleton::getConnector()->shutDown(); 00033 } 00034 } catch (string * err) { 00035 00036 } 00037 }