本文整理汇总了C++中atlas::objects::operation::RootOperation类的典型用法代码示例。如果您正苦于以下问题:C++ RootOperation类的具体用法?C++ RootOperation怎么用?C++ RootOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RootOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: operationGetGoalInfoResult
void EntityEditor::operationGetGoalInfoResult(const Atlas::Objects::Operation::RootOperation& op)
{
//What we receive here has been relayed from the mind of the entity. That means that this op
//is potentially unsafe, as it could be of any type (Set, Logout etc.), all depending on what the
//mind client decided to send (i.e. someone might want to try to hack). We should therefore treat it
//very carefully.
if (op->getClassNo() == Atlas::Objects::Operation::ROOT_OPERATION_NO) {
//An empty root operation signals a timeout; we never got any answer from the entity.
return;
}
//Since we'll just be iterating over the args we only need to do an extra check that what we got is a
//"info" operation.
if (op->getClassNo() != Atlas::Objects::Operation::INFO_NO) {
S_LOG_WARNING("Got goal info operation with wrong type.");
return;
}
if (!op->getArgs().empty()) {
auto goalInfos = op->getArgsAsList();
for (auto goalInfo : goalInfos) {
EventGotGoalInfo(goalInfo);
}
} else {
S_LOG_VERBOSE("Got goal info op without any goals.");
}
}
开发者ID:Laefy,项目名称:ember,代码行数:28,代码来源:EntityEditor.cpp
示例2: removeGoal
void EntityEditor::removeGoal(const std::string& id)
{
Eris::Account* account = EmberServices::getSingleton().getServerService().getAccount();
Atlas::Message::MapType goalElement;
goalElement["id"] = id;
//By not defining anything else than the id we're telling the server to remove it.
Atlas::Objects::Entity::Anonymous thought;
thought->setAttr("goal", goalElement);
Atlas::Objects::Operation::RootOperation thinkOp;
thinkOp->setArgs1(thought);
std::list<std::string> parents;
parents.emplace_back("think");
thinkOp->setParents(parents);
thinkOp->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).
thinkOp->setFrom(mWorld.getAvatar()->getEmberEntity().getId());
Eris::Connection* connection = account->getConnection();
connection->send(thinkOp);
}
开发者ID:Laefy,项目名称:ember,代码行数:25,代码来源:EntityEditor.cpp
示例3: main
int main()
{
ClientConnection * cc = new ClientConnection();
delete cc;
// Try all the method calls when not connected
cc = new ClientConnection();
cc->login("username", "password");
cc->create("player", "username", "password");
cc->wait();
{
Atlas::Objects::Operation::RootOperation op;
cc->send(op);
}
cc->pop();
cc->pending();
delete cc;
TestClientConnection * tcc = new TestClientConnection();
{
Atlas::Objects::Root obj;
Atlas::Objects::Operation::RootOperation op;
tcc->test_operation(op);
tcc->test_errorArrived(op);
tcc->test_infoArrived(op);
tcc->test_objectArrived(op);
Anonymous op_arg;
op->setArgs1(op_arg);
tcc->test_infoArrived(op);
op->setFrom("1");
tcc->test_infoArrived(op);
op->setParents(std::list<std::string>());
tcc->test_operation(op);
tcc->test_objectArrived(op);
Info i;
tcc->test_objectArrived(i);
Error e;
tcc->test_objectArrived(e);
tcc->test_objectArrived(obj);
obj->setParents(std::list<std::string>());
tcc->test_objectArrived(obj);
}
return 0;
}
开发者ID:anthonypesce,项目名称:cyphesis,代码行数:58,代码来源:ClientConnectiontest.cpp
示例4: actuate
void ConnectedAdapter::actuate(Eris::Entity* entity, const std::string& action)
{
try {
Atlas::Objects::Entity::Anonymous what;
what->setId(entity->getId());
// what->setObjtype("obj");
Atlas::Objects::Operation::RootOperation actionOp;
actionOp->setObjtype("op");
actionOp->setArgs1(what);
std::list<std::string> actionParents;
actionParents.push_back(action);
actionOp->setParents(actionParents);
Atlas::Objects::Operation::RootOperation actuateOp;
actuateOp->setObjtype("op");
actuateOp->setArgs1(actionOp);
std::list<std::string> actuateParents;
actuateParents.push_back("actuate");
actuateOp->setParents(actuateParents);
actuateOp->setFrom(mAvatar.getEntity()->getId());
S_LOG_INFO("Actuating entity with id " << entity->getId() << ", named " << entity->getName() << " with action '" << action << "'.");
mConnection.send(actuateOp);
} catch (const std::exception& ex) {
S_LOG_WARNING("Got error on actuating." << ex);
}
}
开发者ID:mpreisler,项目名称:ember,代码行数:29,代码来源:ConnectedAdapter.cpp
示例5: test_operation_account
void Lobbytest::test_operation_account()
{
Account * tac = new TestAccount();
m_lobby->addAccount(tac);
Atlas::Objects::Operation::RootOperation op;
OpVector res;
op->setTo("2");
m_lobby->operation(op, res);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:11,代码来源:Lobbytest.cpp
示例6: test_operation_connected_other
void Lobbytest::test_operation_connected_other()
{
Account * tac = new TestAccount();
tac->m_connection = new Connection(*(CommSocket*)0,
*(ServerRouting*)0,
"foo", "3", 3);
m_lobby->addAccount(tac);
Atlas::Objects::Operation::RootOperation op;
OpVector res;
op->setTo("2");
m_lobby->operation(op, res);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:15,代码来源:Lobbytest.cpp
示例7: broadcast
void LocatedEntity::broadcast(const Atlas::Objects::Operation::RootOperation& op, OpVector& res, Visibility visibility) const
{
std::set<const LocatedEntity*> receivers;
collectObservers(receivers);
for (auto& entity : receivers) {
if (visibility == Visibility::PRIVATE) {
//Only send private ops to admins
if (!entity->hasFlags(entity_admin)) {
continue;
}
} else if (visibility == Visibility::PROTECTED) {
//Protected ops also goes to the entity itself
if (!entity->hasFlags(entity_admin) &&
entity->getIntId() != getIntId()) {
continue;
}
}
auto newOp = op.copy();
newOp->setTo(entity->getId());
newOp->setFrom(getId());
res.push_back(newOp);
}
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:25,代码来源:LocatedEntity.cpp
示例8: Entity_Action
void SoundEntity::Entity_Action(const Atlas::Objects::Operation::RootOperation& act)
{
const std::list<std::string> &p = act->getParents();
std::list<std::string>::const_iterator I = p.begin();
if (I != p.end()) {
const std::string& name = *I;
playAction(name);
}
}
开发者ID:Arsakes,项目名称:ember,代码行数:10,代码来源:SoundEntity.cpp
示例9: addKnowledge
void EntityEditor::addKnowledge(const std::string& predicate, const std::string& subject, const std::string& knowledge)
{
Eris::Account* account = EmberServices::getSingleton().getServerService().getAccount();
Atlas::Objects::Entity::Anonymous thought;
thought->setAttr("predicate", predicate);
thought->setAttr("subject", subject);
thought->setAttr("object", knowledge);
Atlas::Objects::Operation::RootOperation thinkOp;
thinkOp->setArgs1(thought);
std::list<std::string> parents;
parents.emplace_back("think");
thinkOp->setParents(parents);
thinkOp->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).
thinkOp->setFrom(mWorld.getAvatar()->getEmberEntity().getId());
Eris::Connection* connection = account->getConnection();
connection->send(thinkOp);
}
开发者ID:Laefy,项目名称:ember,代码行数:24,代码来源:EntityEditor.cpp
示例10: onAction
void EmberEntity::onAction(const Atlas::Objects::Operation::RootOperation& act)
{
const std::list<std::string> &p = act->getParents();
std::list<std::string>::const_iterator I = p.begin();
if (I != p.end()) {
const std::string& name = *I;
std::string message = getName() + " performs a " + name + ".";
ConsoleBackend::getSingletonPtr()->pushMessage(message, "info");
S_LOG_VERBOSE("Entity: " << this->getId() << " (" << this->getName() << ") action: " << name);
}
Entity::onAction(act);
}
开发者ID:Laefy,项目名称:ember,代码行数:16,代码来源:EmberEntity.cpp
示例11: onSoundAction
void EmberEntity::onSoundAction(const Atlas::Objects::Operation::RootOperation & op)
{
//We'll just catch the call and write something to both the log and the console, and then pass it on.
const std::list<std::string> &p = op->getParents();
std::list<std::string>::const_iterator I = p.begin();
if (I != p.end()) {
const std::string& name = *I;
std::string message = getName() + " emits a " + name + ".";
ConsoleBackend::getSingletonPtr()->pushMessage(message, "info");
S_LOG_VERBOSE("Entity: " << this->getId() << " (" << this->getName() << ") sound action: " << name);
}
Eris::Entity::onSoundAction(op);
}
开发者ID:Laefy,项目名称:ember,代码行数:18,代码来源:EmberEntity.cpp
示例12: sendMinds
void EntityImporterBase::sendMinds()
{
if (!mResolvedMindMapping.empty()) {
S_LOG_INFO("Sending minds.");
for (auto mind : mResolvedMindMapping) {
Atlas::Message::MapType message;
mind.second->addToMessage(message);
Atlas::Message::Element thoughtsElem = message["thoughts"];
Atlas::Message::ListType thoughtArgs;
if (thoughtsElem.isList()) {
Atlas::Message::ListType thoughtList = thoughtsElem.List();
for (auto& thought : thoughtList) {
//If the thought is a list of things the entity owns, we should adjust it with the new entity ids.
if (thought.isMap()) {
auto& thoughtMap = thought.Map();
if (thoughtMap.count("things") > 0) {
auto& thingsElement = thoughtMap.find("things")->second;
if (thingsElement.isMap()) {
for (auto& thingI : thingsElement.asMap()) {
if (thingI.second.isList()) {
Atlas::Message::ListType newList;
for (auto& thingId : thingI.second.asList()) {
if (thingId.isString()) {
const auto& entityIdLookupI = mEntityIdMap.find(thingId.asString());
//Check if the owned entity has been created with a new id. If so, replace the data.
if (entityIdLookupI != mEntityIdMap.end()) {
newList.emplace_back(entityIdLookupI->second);
} else {
newList.push_back(thingId);
}
} else {
newList.push_back(thingId);
}
}
thingI.second = newList;
}
}
}
}
if (thoughtMap.count("pending_things") > 0) {
//things that the entity owns, but haven't yet discovered are expressed as a list of entity ids
auto& pendingThingsElement = thoughtMap.find("pending_things")->second;
if (pendingThingsElement.isList()) {
Atlas::Message::ListType newList;
for (auto& thingId : pendingThingsElement.asList()) {
if (thingId.isString()) {
const auto& entityIdLookupI = mEntityIdMap.find(thingId.asString());
//Check if the owned entity has been created with a new id. If so, replace the data.
if (entityIdLookupI != mEntityIdMap.end()) {
newList.emplace_back(entityIdLookupI->second);
} else {
newList.push_back(thingId);
}
} else {
newList.push_back(thingId);
}
}
pendingThingsElement = newList;
}
}
if (thoughtMap.count("object") > 0) {
auto& objectElement = thoughtMap.find("object")->second;
if (objectElement.isString()) {
std::string& objectString = objectElement.String();
//Other entities are referred to using the syntax "'$eid:...'".
//For example, the entity with id 2 would be "'$eid:2'".
auto pos = objectString.find("$eid:");
if (pos != std::string::npos) {
auto quotePos = objectString.find('\'', pos);
if (quotePos != std::string::npos) {
auto id = objectString.substr(pos + 5, quotePos - pos - 5);
auto I = mEntityIdMap.find(id);
if (I != mEntityIdMap.end()) {
objectString.replace(pos + 5, quotePos - 7, I->second);
}
}
}
}
}
}
thoughtArgs.push_back(thought);
}
}
Atlas::Objects::Operation::RootOperation thinkOp;
thinkOp->setParent("think");
thinkOp->setTo(mind.first);
//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).
thinkOp->setFrom(mAvatarId);
thinkOp->setSerialno(newSerialNumber());
Atlas::Objects::Operation::Set setOp;
setOp->setArgsAsList(thoughtArgs);
//.........这里部分代码省略.........
开发者ID:worldforge,项目名称:cyphesis,代码行数:101,代码来源:EntityImporterBase.cpp
示例13: main
int main()
{
TestWorld world;
CommServer server;
{
Peer * p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
delete p;
}
{
Peer * p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
Atlas::Objects::Operation::RootOperation op;
OpVector res;
p->operation(op, res);
delete p;
}
{
// Test the setting of authentiaction states
Peer * p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
assert(p->getAuthState() == PEER_INIT);
p->setAuthState(PEER_AUTHENTICATED);
assert(p->getAuthState() == PEER_AUTHENTICATED);
delete p;
}
{
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
Atlas::Objects::Operation::Info op;
OpVector res;
p->operation(op, res);
}
// Authenticating (no args)
{
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
p->setAuthState(PEER_AUTHENTICATING);
Atlas::Objects::Operation::Info op;
OpVector res;
p->operation(op, res);
}
// Authenticating (empty arg)
{
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
p->setAuthState(PEER_AUTHENTICATING);
Atlas::Objects::Operation::Info op;
Atlas::Objects::Root arg;
op->setArgs1(arg);
OpVector res;
p->operation(op, res);
}
// Authenticating (full arg)
{
TestPeer *p = new TestPeer(*(CommSocket*)0, *(ServerRouting*)0, "addr", "1", 1);
p->setAuthState(PEER_AUTHENTICATING);
Atlas::Objects::Operation::Info op;
Atlas::Objects::Root arg;
arg->setId("2");
std::list<std::string> parents;
parents.push_back("server");
arg->setParents(parents);
op->setArgs1(arg);
OpVector res;
p->operation(op, res);
assert(p->getAccountType() == "server");
}
// Authenticated (no args)
{
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
p->setAuthState(PEER_AUTHENTICATED);
Atlas::Objects::Operation::Info op;
OpVector res;
p->operation(op, res);
}
{
Peer *p = new Peer(*(CommSocket*)0, *(ServerRouting*)0, "addr", 6767, "1", 1);
Atlas::Objects::Operation::Error op;
OpVector res;
p->operation(op, res);
}
//.........这里部分代码省略.........
开发者ID:anthonypesce,项目名称:cyphesis,代码行数:101,代码来源:Peertest.cpp
示例14: main
//.........这里部分代码省略.........
delete cs;
}
{
TestCommClient * cs = new TestCommClient(comm_server);
cs->test_setConnectTime(0);
cs->test_idle(20);
delete cs;
}
{
TestCommClient * cs = new TestCommClient(comm_server);
cs->read();
delete cs;
}
{
TestCommClient * cs = new TestCommClient(comm_server);
cs->test_setEncoder();
cs->read();
delete cs;
}
{
TestCommClient * cs = new TestCommClient(comm_server);
Atlas::Objects::Operation::RootOperation op;
cs->send(op);
delete cs;
}
{
TestCommClient * cs = new TestCommClient(comm_server);
cs->test_openSocket();
Atlas::Objects::Operation::RootOperation op;
cs->send(op);
delete cs;
}
{
TestCommClient * cs = new TestCommClient(comm_server);
cs->test_openSocket();
cs->test_setEncoder();
Atlas::Objects::Operation::RootOperation op;
cs->send(op);
delete cs;
}
{
TestCommClient * cs = new TestCommClient(comm_server);
cs->test_setConnection(new TestLink(*cs));
开发者ID:anthonypesce,项目名称:cyphesis,代码行数:67,代码来源:CommClienttest.cpp
示例15: send
int CommClient::send(const Atlas::Objects::Operation::RootOperation & op)
{
stub_connection_send_op = op->getClassNo();
++stub_connection_send_count;
return 0;
}
开发者ID:erikogenvik,项目名称:cyphesis,代码行数:6,代码来源:ExternalMindtest.cpp
注:本文中的atlas::objects::operation::RootOperation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论