void ObjectHost::commandCreateObject(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) { Command::Result result = Command::EmptyResult(); if (!cmd.contains("script.type")) { result.put("error", "Must specify at least script.type"); cmdr->result(cmdid, result); return; } String scriptType = cmd.getString("script.type"); String scriptOpts = cmd.getString("script.opts", ""); String scriptContents = cmd.getString("script.contents", ""); HostedObjectPtr obj; obj = createObject(scriptType, scriptOpts, scriptContents); result.put("id", obj->id().toString()); cmdr->result(cmdid, result); }
ManualObjectQueryProcessor::ObjectQueryHandlerPtr ManualObjectQueryProcessor::lookupCommandHandler(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) const { ObjectQueryHandlerPtr result; if (cmd.contains("handler")) { String handler_name = cmd.getString("handler"); // Only the first part of the handler name is the SpaceNodeID we need to // look up the ObjectQueryHandler handler_name = handler_name.substr(0, handler_name.find('.')); OHDP::SpaceNodeID snid(handler_name); QueryHandlerMap::const_iterator it = mObjectQueryHandlers.find(snid); if (it != mObjectQueryHandlers.end()) result = it->second; } if (!result) { Command::Result result = Command::EmptyResult(); result.put("error", "Ill-formatted request: handler not specified or invalid."); cmdr->result(cmdid, result); } return result; }
HostedObjectPtr ObjectHost::getCommandObject(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) { String obj_string = cmd.getString("object", ""); UUID objid(obj_string, UUID::HumanReadable()); if (objid == UUID::null()) { // not specified, not parsed Command::Result result = Command::EmptyResult(); result.put("error", "Ill-formatted request: no object specified for disconnect."); cmdr->result(cmdid, result); return HostedObjectPtr(); } HostedObjectPtr ho = getHostedObject(objid); if (!ho) { Command::Result result = Command::EmptyResult(); result.put("error", "Object not found"); cmdr->result(cmdid, result); return HostedObjectPtr(); } return ho; }