Beispiel #1
0
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;
}