Example #1
0
void EntityEditor::getGoalInfo(const std::string& id)
{

	Eris::Account* account = EmberServices::getSingleton().getServerService().getAccount();

	Atlas::Objects::Operation::Generic get;
	std::list<std::string> parents;
	parents.emplace_back("commune");
	get->setParents(parents);
	get->setTo(mEntity.getId());

	//By setting it TO an entity and FROM our avatar we'll make the server deliver it as
	//if it came from the entity itself (the server rewrites the FROM to be of the entity).
	get->setFrom(mWorld.getAvatar()->getEmberEntity().getId());
	//By setting a serial number we tell the server to "relay" the operation. This means that any
	//response operation from the target entity will be sent back to us.
	get->setSerialno(Eris::getNewSerialno());

	Atlas::Message::MapType goalMap;
	goalMap["id"] = id;
	Atlas::Objects::Entity::Anonymous getArg;
	getArg->setAttr("goal_info", goalMap);
	get->setArgs1(getArg);

	Eris::Connection* connection = account->getConnection();

	connection->getResponder()->await(get->getSerialno(), this, &EntityEditor::operationGetGoalInfoResult);
	connection->send(get);
}
Example #2
0
void ConnectedAdapter::eat(Eris::Entity* entity)
{
	try {
		Atlas::Objects::Entity::Anonymous what;
		what->setId(entity->getId());

		Atlas::Objects::Operation::Generic op;
		op->setType("eat", -1);
		op->setFrom(mAvatar.getEntity()->getId());
		op->setArgs1(what);

		S_LOG_INFO("Eating entity with id " << entity->getId() << ", named " << entity->getName());
		mConnection.send(op);
	} catch (const std::exception& ex) {
		S_LOG_WARNING("Got error on eating entity." << ex);
	}
}