예제 #1
0
/// \brief Report an Error.
///
/// The error reported is noted in the log, and an error operation is
/// genereated.
/// @param op The operation that caused the error.
/// @param errstring A message describing the error.
/// @param res The resulting error operation is returned here.
/// @param to The error operation should be directed to this ID.
void Router::error(const Operation & op,
                   const std::string & errstring,
                   OpVector & res,
                   const std::string & to) const
{
    Atlas::Objects::Operation::Error e;

    log(NOTICE, String::compose("ERROR generated by %1 with message [%2]",
                                getId(), errstring));

    std::vector<Atlas::Objects::Root> & args = e->modifyArgs();

    Atlas::Objects::Entity::Anonymous arg1;
    arg1->setAttr("message", errstring);
    args.push_back(arg1);
    args.push_back(op);

    if (!to.empty()) {
        if (!op->isDefaultSerialno()) {
            e->setRefno(op->getSerialno());
        }
        e->setTo(to);
    }

    res.push_back(e);
}
예제 #2
0
Py::Object CyPy_Task::irrelevant(const Py::Tuple& args)
{
    m_value->irrelevant();
    if (args.size() > 0) {
        args.verify_length(1);
        Atlas::Objects::Operation::Error e;
        Atlas::Objects::Entity::Anonymous arg;
        arg->setAttr("message", verifyString(args.front()));
        e->modifyArgs().push_back(arg);
        e->setTo(m_value->m_usageInstance.actor->getId());
        return CyPy_Operation::wrap(e);
    }
    return Py::None();
}
예제 #3
0
/// \brief Report an Error to a client.
///
/// The error reported generates an error operation.
/// This is used instead of error() when an event occurs which is of no
/// interest to the server admin, or world builder, and should only be
/// be reported to the client. It stops the logs from getting filled
/// with reports of authentication failures, and other similar occurences.
/// @param op The operation that caused the error.
/// @param errstring A message describing the error.
/// @param res The resulting error operation is returned here.
/// @param to The error operation should be directed to this ID.
void Router::clientError(const Operation & op,
                         const std::string & errstring,
                         OpVector & res,
                         const std::string & to) const
{
    Atlas::Objects::Operation::Error e;

    std::vector<Atlas::Objects::Root> & args = e->modifyArgs();

    Atlas::Objects::Entity::Anonymous arg1;
    arg1->setAttr("message", errstring);
    args.push_back(arg1);
    args.push_back(op);

    if (!to.empty()) {
        if (!op->isDefaultSerialno()) {
            e->setRefno(op->getSerialno());
        }
        e->setTo(to);
    }

    res.push_back(e);
}
int main()
{
    {
        AtlasStreamClient * asc = new AtlasStreamClient;

        delete asc;
    }

    TestAtlasStreamClient * asc = new TestAtlasStreamClient;

    {
        Atlas::Objects::Root obj;
        asc->test_objectArrived(obj);
        obj->setParents(std::list<std::string>());
        asc->test_objectArrived(obj);
        obj->setParents(std::list<std::string>(1, "foo"));
        asc->test_objectArrived(obj);
        obj->setObjtype("foo");
        asc->test_objectArrived(obj);
    }

    Operation op;
    asc->test_objectArrived(op);
    asc->test_operation(op);

    TestClientTask * tct = new TestClientTask();
    // Test starting a task
    asc->runTask(tct, "foo");
    assert(asc->test_currentTask() == tct);
    // Try and start it again will busy, as one is running
    asc->runTask(new TestClientTask(), "foo");
    assert(asc->test_currentTask() == tct);
    
    asc->endTask();
    assert(asc->test_currentTask() == 0);
    asc->endTask();
    assert(asc->test_currentTask() == 0);

    tct = new TestClientTask();
    asc->runTask(tct, "foo");
    // Pass in an operation while a task is running.
    asc->test_operation(op);
    assert(asc->test_currentTask() == tct);
    tct->make_complete();
    asc->test_operation(op);
    assert(asc->test_currentTask() == 0);

    tct = new TestClientTask();
    asc->runTask(tct, "foo");
    assert(asc->test_currentTask() == tct);
    // Pass in an operation while a task is running.
    asc->test_operation(op);
    assert(asc->test_currentTask() == tct);

    {
        Atlas::Objects::Operation::Info op;

        asc->test_operation(op);
        Atlas::Objects::Entity::Anonymous arg;
        op->setArgs1(arg);
        asc->test_operation(op);
        op->setRefno(23);
        asc->test_operation(op);
        op->setRefno(asc->newSerialNo());
        asc->test_operation(op);
        op->setFrom("1");
        asc->test_operation(op);
    }

    {
        Atlas::Objects::Operation::Error op;

        asc->test_operation(op);
        Atlas::Objects::Entity::Anonymous arg;
        op->setArgs1(arg);
        asc->test_operation(op);
        arg->setAttr("message", 1);
        asc->test_operation(op);
        arg->setAttr("message", "Real message");
        asc->test_operation(op);
    }

    {
        Atlas::Objects::Operation::Appearance op;

        asc->test_operation(op);
    }

    {
        Atlas::Objects::Operation::Disappearance op;

        asc->test_operation(op);
    }

    {
        Atlas::Objects::Operation::Sight op;

        asc->test_operation(op);
    }

    {
        Atlas::Objects::Operation::Sound op;

        asc->test_operation(op);
    }
    assert(asc->test_currentTask() == tct);

    // Verify these bale out cleanly when unconnected
    asc->poll();
    asc->login("foo", "bar");
    asc->create("player", "foo", "bar");

    int ret = asc->connect("localhost", 2323);
    assert(ret != 0);
    ret = asc->connectLocal("/sys/thereisnofilehere");
    assert(ret != 0);

}