Esempio n. 1
0
void ConnectedAdapter::setAttributes(Eris::Entity* entity, Atlas::Message::MapType& elements)
{
	try {
		Atlas::Objects::Entity::Anonymous what;
		what->setId(entity->getId());
		//We'll use this flag to make sure that nothing gets sent in the case that the only thing changed was immutable attributes (like "pos").
		bool areAttributesToSend = false;
		for (Atlas::Message::MapType::iterator I = elements.begin(); I != elements.end(); ++I) {
			//The "pos" attribute is immutable and cannot be altered by a "set" op. Instead we must use a "move" op.
			if (I->first == "pos") {
				place(entity, entity->getLocation(), WFMath::Point<3>(I->second));
			} else {
				what->setAttr(I->first, I->second);
				areAttributesToSend = true;
			}
		}

		if (areAttributesToSend) {
			Atlas::Objects::Operation::Set setOp;
			setOp->setFrom(mAvatar.getEntity()->getId());
			//setOp->setTo(entity->getId());
			setOp->setArgs1(what);

			S_LOG_INFO("Setting attributes of entity with id " << entity->getId() << ", named " << entity->getName());
			mConnection.send(setOp);
		}
	} catch (const std::exception& ex) {
		S_LOG_WARNING("Got error on setting attributes on entity." << ex);
	}
}
Esempio n. 2
0
void ConnectedAdapter::setTypeInfo(const Atlas::Objects::Root& typeInfo)
{
	try {
		Atlas::Objects::Operation::Set setOp;
		setOp->setFrom(mAccount.getId());
		setOp->setArgs1(typeInfo);

		S_LOG_INFO("Sending updated type info data.");
		mConnection.send(setOp);
	} catch (const std::exception& ex) {
		S_LOG_WARNING("Got error on sending updated type info data." << ex);
	}
}
Esempio n. 3
0
void EntityImporterBase::updateRule(const Root& existingDefinition, const Root& newDefinition, OpVector & res)
{

    m_state = RULE_UPDATING;
    Root updatedDefinition = newDefinition.copy();

    //If the existing definition had any children that aren't part of the import, we should preserve those
    std::list<std::string> existingChildren, newChildren;
    extractChildren(existingDefinition, existingChildren);
    extractChildren(newDefinition, newChildren);

    for (auto& child : newChildren) {
        existingChildren.remove(child);
    }

    for (auto& child : existingChildren) {
        if (mPersistedRules.find(child) == mPersistedRules.end()) {
            newChildren.push_back(child);
        }
    }

    if (!newChildren.empty() && !existingChildren.empty()) {
        Atlas::Message::ListType childrenElement;
        for (auto& child : newChildren) {
            childrenElement.emplace_back(child);
        }
        updatedDefinition->setAttr("children", childrenElement);
    }

    if (updatedDefinition->asMessage() != existingDefinition->asMessage()) {
        S_LOG_INFO("Updating server rule '"<< updatedDefinition->getId() << "'.");
        Atlas::Objects::Operation::Set setOp;
        setOp->setFrom(mAccountId);
        setOp->setArgs1(updatedDefinition);

        setOp->setSerialno(newSerialNumber());
        res.push_back(setOp);
    } else {
        mStats.rulesProcessedCount++;
        EventProgress.emit();
        S_LOG_VERBOSE("Not updating server rule '"<< updatedDefinition->getId() << "' as nothing is changed.");
        walkRules(res);
    }
}