[dss-commits] r8850 - dss/trunk/core
dss-commits at forum.digitalstrom.org
dss-commits at forum.digitalstrom.org
Fri Oct 16 11:52:09 CEST 2009
Author: pstaehlin
Date: 2009-10-16 11:52:09 +0200 (Fri, 16 Oct 2009)
New Revision: 8850
Modified:
dss/trunk/core/webserver.cpp
Log:
Allow passing parameter to an event in JSON
Modified: dss/trunk/core/webserver.cpp
===================================================================
--- dss/trunk/core/webserver.cpp 2009-10-15 14:12:08 UTC (rev 8849)
+++ dss/trunk/core/webserver.cpp 2009-10-16 09:52:09 UTC (rev 8850)
@@ -1326,15 +1326,29 @@
string name = _parameter["name"];
string location = _parameter["location"];
string context = _parameter["context"];
+ string parameter = _parameter["parameter"];
- boost::shared_ptr<Event> e(new Event(name));
+ boost::shared_ptr<Event> evt(new Event(name));
if(!context.empty()) {
- e->setContext(context);
+ evt->setContext(context);
}
if(!location.empty()) {
- e->setLocation(location);
+ evt->setLocation(location);
}
- getDSS().getEventQueue().pushEvent(e);
+ std::vector<std::string> params = dss::splitString(parameter, ';');
+ for(std::vector<std::string>::iterator iParam = params.begin(), e = params.end();
+ iParam != e; ++iParam)
+ {
+ std::vector<std::string> nameValue = dss::splitString(*iParam, '=');
+ if(nameValue.size() == 2) {
+ dss::Logger::getInstance()->log("WebServer::handleEventCall: Got parameter '" + nameValue[0] + "'='" + nameValue[1] + "'");
+ evt->setProperty(nameValue[0], nameValue[1]);
+ } else {
+ dss::Logger::getInstance()->log(string("Invalid parameter found WebServer::handleEventCall: ") + *iParam );
+ }
+ }
+
+ getDSS().getEventQueue().pushEvent(evt);
return ResultToJSON(true);
} else {
_handled = false;
More information about the dss-commits
mailing list