Ejemplo n.º 1
0
void Dispatcher::handleReplyReceived(const JoynrMessage& message)
{
    // json request
    // lookup necessary data
    std::string jsonReply = message.getPayload();

    // deserialize the jsonReply
    try {
        Reply reply = JsonSerializer::deserialize<Reply>(jsonReply);
        std::string requestReplyId = reply.getRequestReplyId();

        std::shared_ptr<IReplyCaller> caller = replyCallerDirectory.lookup(requestReplyId);
        if (caller == nullptr) {
            // This used to be a fatal error, but it is possible that the replyCallerDirectory
            // removed
            // the caller
            // because its lifetime exceeded TTL
            JOYNR_LOG_INFO(
                    logger,
                    "caller not found in the ReplyCallerDirectory for requestid {}, ignoring",
                    requestReplyId);
            return;
        }

        // Get the reply interpreter - this has to be a reference to support ReplyInterpreter
        // polymorphism
        int typeId = caller->getTypeId();
        IReplyInterpreter& interpreter = MetaTypeRegistrar::instance().getReplyInterpreter(typeId);

        // pass reply
        interpreter.execute(caller, reply);

        // Clean up
        removeReplyCaller(requestReplyId);
    } catch (const std::invalid_argument& e) {
        JOYNR_LOG_ERROR(logger,
                        "Unable to deserialize reply object from: {} - error {}",
                        jsonReply,
                        e.what());
    }
}
Ejemplo n.º 2
0
void Dispatcher::handleReplyReceived(const JoynrMessage& message)
{
    // json request
    // lookup necessary data
    QByteArray jsonReply = message.getPayload();

    // deserialize the jsonReply
    Reply* reply = JsonSerializer::deserialize<Reply>(jsonReply);
    if (reply == Q_NULLPTR) {
        LOG_ERROR(logger,
                  QString("Unable to deserialize reply object from: %1")
                          .arg(QString::fromUtf8(jsonReply)));
        return;
    }
    QString requestReplyId = reply->getRequestReplyId();

    QSharedPointer<IReplyCaller> caller = replyCallerDirectory.lookup(requestReplyId.toStdString());
    if (caller == NULL) {
        // This used to be a fatal error, but it is possible that the replyCallerDirectory removed
        // the caller
        // because its lifetime exceeded TTL
        LOG_INFO(logger,
                 "caller not found in the ReplyCallerDirectory for requestid " + requestReplyId +
                         ", ignoring");
        return;
    }

    // Get the reply interpreter - this has to be a reference to support ReplyInterpreter
    // polymorphism
    int typeId = caller->getTypeId();
    IReplyInterpreter& interpreter = MetaTypeRegistrar::instance().getReplyInterpreter(typeId);

    // pass reply
    interpreter.execute(caller, *reply);

    // Clean up
    delete reply;
    removeReplyCaller(requestReplyId.toStdString());
}
Ejemplo n.º 3
0
Reply::Reply(const Reply &other) :
    QObject(),
    requestReplyId(other.getRequestReplyId()),
    response(other.response)
{
}
Ejemplo n.º 4
0
bool Reply::operator==(const Reply& other) const {
    return requestReplyId == other.getRequestReplyId()
            && response == other.getResponse();
}
Ejemplo n.º 5
0
Reply::Reply(const Reply& other)
        : requestReplyId(other.getRequestReplyId()), response(other.response), error(other.error)
{
}