void HostedObject::commandPresences( const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) { Command::Result result = Command::EmptyResult(); // Make sure we return the objects key set even if there are none result.put( String("presences"), Command::Object()); Command::Object& presences_map = result.getObject("presences"); { Mutex::scoped_lock locker(presenceDataMutex); for(PresenceDataMap::const_iterator presit = mPresenceData.begin(); presit != mPresenceData.end(); presit++) { Command::Object presdata; // Should fill in basic presence info but it's a pain to serialize // here (loc, orientation, etc). presdata["mesh"] = presit->second->requestLoc->mesh().toString(); presdata["physics"] = presit->second->requestLoc->physics(); Command::Object proxy_data; proxy_data["alive"] = presit->second->proxyManager->size(); proxy_data["active"] = presit->second->proxyManager->activeSize(); presdata["proxies"] = proxy_data; presences_map[presit->first.toString()] = presdata; } } cmdr->result(cmdid, result); }
void ObjectHost::commandDestroyObject(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) { HostedObjectPtr ho = getCommandObject(cmd, cmdr, cmdid); if (!ho) return; Command::Result result = Command::EmptyResult(); ho->stop(); ho->destroy(); result.put("success", true); cmdr->result(cmdid, result); }
void ManualObjectQueryProcessor::commandListQueriers(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) { Command::Result result = Command::EmptyResult(); // Organized as lists under queriers.type, each querier being a dict of query handlers -> stats result.put("queriers.object", Command::Object()); result.put("queriers.oh", Command::Object()); result.put("queriers.server", Command::Object()); // Each object is registered with only one server, so just loop through our // per-server handlers for queriers for(QueryHandlerMap::iterator handler_it = mObjectQueryHandlers.begin(); handler_it != mObjectQueryHandlers.end(); handler_it++) handler_it->second->commandListQueriers(handler_it->first, result); cmdr->result(cmdid, result); }
void ObjectHost::commandListObjects(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) { Command::Result result = Command::EmptyResult(); // Make sure we return the objects key set even if there are none result.put( String("objects"), Command::Array()); Command::Array& objects_ary = result.getArray("objects"); Sirikata::SerializationCheck::Scoped sc(&mSessionSerialization); for(InternalIDHostedObjectMap::const_iterator it = mHostedObjectsByID.begin(); it != mHostedObjectsByID.end(); it++) { HostedObjectPtr ho = it->second.lock(); if (ho) objects_ary.push_back( ho->id().toString() ); } cmdr->result(cmdid, result); }
void IOService::commandReportAllStats(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) { #ifdef SIRIKATA_TRACK_EVENT_QUEUES AllIOServicesLockGuard lock(gAllIOServicesMutex); Command::Result result = Command::EmptyResult(); // Ensure the top-level structure is there result.put("ioservices", Command::Array()); Command::Array& services = result.getArray("ioservices"); for(AllIOServicesSet::const_iterator it = gAllIOServices.begin(); it != gAllIOServices.end(); it++) { services.push_back(Command::Object()); (*it)->fillCommandResultWithStats(services.back()); } cmdr->result(cmdid, result); #endif }
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; }
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; }
void ManualObjectQueryProcessor::commandProperties(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) { Command::Result result = Command::EmptyResult(); result.put("name", "libprox-manual"); result.put("settings.handlers", mObjectQueryHandlers.size()); result.put("queries.server.count", mServerQueryHandler.numQueries()); result.put("queries.server.messages", mServerQueryHandler.numQueryMessages()); { uint32 count = 0, messages = 0; for(QueryHandlerMap::const_iterator it = mObjectQueryHandlers.begin(); it != mObjectQueryHandlers.end(); it++) { count += it->second->objectQueries(); messages += it->second->objectQueryMessages(); } result.put("queries.objects.count", count); result.put("queries.objects.messages", messages); } cmdr->result(cmdid, result); }
void IOService::fillCommandResultWithStats(Command::Result& res) { LockGuard lock(const_cast<Mutex&>(mMutex)); res.put("name", name()); res.put("timers.enqueued", numTimersEnqueued()); res.put("timers.latency", timerLatency().toString()); res.put("handlers.enqueued", numEnqueued()); res.put("handlers.latency", handlerLatency().toString()); reportOffenders(mTagCounts, res, "offenders"); res.put("strands", Command::Array()); Command::Array& strands = res.getArray("strands"); for(StrandSet::const_iterator it = mStrands.begin(); it != mStrands.end(); it++) { strands.push_back(Command::Object()); strands.back().put("name", (*it)->name()); strands.back().put("timers.enqueued", (*it)->numTimersEnqueued()); strands.back().put("timers.latency", (*it)->timerLatency().toString()); strands.back().put("handlers.enqueued", (*it)->numEnqueued()); strands.back().put("handlers.latency", (*it)->handlerLatency().toString()); reportOffenders((*it)->enqueuedTags(), strands.back(), "offenders"); } }
void ManualObjectQueryProcessor::commandStats(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) { Command::Result result = Command::EmptyResult(); result.put( String("stats"), Command::EmptyResult()); cmdr->result(cmdid, result); }
void SimpleCameraObjectScript::handleObjectCommand(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) { Command::Result result = Command::EmptyResult(); result.put("error", "SimpleCameraObjectScripts don't handle commands"); cmdr->result(cmdid, result); }