本文整理汇总了C++中JoynrMessage::getPayload方法的典型用法代码示例。如果您正苦于以下问题:C++ JoynrMessage::getPayload方法的具体用法?C++ JoynrMessage::getPayload怎么用?C++ JoynrMessage::getPayload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JoynrMessage
的用法示例。
在下文中一共展示了JoynrMessage::getPayload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: receive
void Dispatcher::receive(const JoynrMessage& message)
{
LOG_DEBUG(logger,
QString("receive(message). Message payload: %1").arg(QString(message.getPayload())));
ReceivedMessageRunnable* receivedMessageRunnable = new ReceivedMessageRunnable(message, *this);
handleReceivedMessageThreadPool.start(receivedMessageRunnable);
}
示例2: checkSubscriptionPublication
void checkSubscriptionPublication(const JoynrMessage& joynrMessage){
QString expectedPayload = QString(
"{\"_typeName\":\"joynr.SubscriptionPublication\","
"\"response\":\"publication\","
"\"subscriptionId\":\"%1\"}"
);
expectedPayload = expectedPayload.arg(subscriptionPublication.getSubscriptionId());
EXPECT_EQ(expectedPayload, QString(joynrMessage.getPayload()));
}
示例3: checkReply
void checkReply(const JoynrMessage& joynrMessage){
QString expectedPayload = QString(
"{\"_typeName\":\"joynr.Reply\","
"\"requestReplyId\":\"%1\","
"\"response\":\"response\"}"
);
expectedPayload = expectedPayload.arg(reply.getRequestReplyId());
EXPECT_EQ(expectedPayload, QString(joynrMessage.getPayload()));
}
示例4: checkRequest
void checkRequest(const JoynrMessage& joynrMessage){
//TODO create expected string from params and methodName
QString expectedPayload = QString(
"{\"_typeName\":\"joynr.Request\","
"\"methodName\":\"methodName\","
"\"paramDatatypes\":[\"java.lang.Integer\",\"java.lang.String\"],"
"\"params\":[42,\"value\"],"
"\"requestReplyId\":\"%1\"}"
);
expectedPayload = expectedPayload.arg(request.getRequestReplyId());
EXPECT_EQ(expectedPayload, QString(joynrMessage.getPayload()));
}
示例5: transmit
void DbusMessagingStubAdapter::transmit(JoynrMessage& message)
{
logMethodCall(QString("transmit message with ID: %1 and payload: %2")
.arg(message.getHeaderMessageId())
.arg(QString(message.getPayload())));
// copy joynr message
joynr::messaging::IMessaging::JoynrMessage dbusMsg;
DbusMessagingUtil::copyJoynrMsgToDbusMsg(message, dbusMsg);
// call
CommonAPI::CallStatus status;
proxy->transmit(dbusMsg, status);
// print the status
printCallStatus(status, "transmit");
}
示例6: handleSubscriptionStopReceived
void Dispatcher::handleSubscriptionStopReceived(const JoynrMessage& message)
{
LOG_DEBUG(logger, "handleSubscriptionStopReceived");
QByteArray jsonSubscriptionStop = message.getPayload();
SubscriptionStop* subscriptionStop =
JsonSerializer::deserialize<SubscriptionStop>(jsonSubscriptionStop);
if (subscriptionStop == Q_NULLPTR) {
LOG_ERROR(logger,
QString("Unable to deserialize subscription stop object from: %1")
.arg(QString::fromUtf8(jsonSubscriptionStop)));
return;
}
QString subscriptionId = subscriptionStop->getSubscriptionId();
assert(publicationManager != NULL);
publicationManager->stopPublication(subscriptionId);
}
示例7: handleReplyReceived
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());
}
}
示例8: handleSubscriptionStopReceived
void Dispatcher::handleSubscriptionStopReceived(const JoynrMessage& message)
{
JOYNR_LOG_DEBUG(logger, "handleSubscriptionStopReceived");
std::string jsonSubscriptionStop = message.getPayload();
std::string subscriptionId;
try {
SubscriptionStop subscriptionStop =
JsonSerializer::deserialize<SubscriptionStop>(jsonSubscriptionStop);
subscriptionId = subscriptionStop.getSubscriptionId();
} catch (const std::invalid_argument& e) {
JOYNR_LOG_ERROR(logger,
"Unable to deserialize subscription stop object from: {} - error: {}",
jsonSubscriptionStop,
e.what());
return;
}
assert(publicationManager != nullptr);
publicationManager->stopPublication(subscriptionId);
}
示例9: handleBroadcastSubscriptionRequestReceived
void Dispatcher::handleBroadcastSubscriptionRequestReceived(const JoynrMessage& message)
{
JOYNR_LOG_TRACE(logger, "Starting handleBroadcastSubscriptionRequestReceived");
// Make sure that noone is registering a Caller at the moment, because a racing condition could
// occour.
std::lock_guard<std::mutex> lock(subscriptionHandlingMutex);
assert(publicationManager != nullptr);
std::string receiverId = message.getHeaderTo();
std::shared_ptr<RequestCaller> caller = requestCallerDirectory.lookup(receiverId);
std::string jsonSubscriptionRequest = message.getPayload();
// PublicationManager is responsible for deleting SubscriptionRequests
try {
BroadcastSubscriptionRequest subscriptionRequest =
JsonSerializer::deserialize<BroadcastSubscriptionRequest>(jsonSubscriptionRequest);
if (!caller) {
// Provider not registered yet
// Dispatcher will call publicationManger->restore when a new provider is added to
// activate
// subscriptions for that provider
publicationManager->add(
message.getHeaderFrom(), message.getHeaderTo(), subscriptionRequest);
} else {
publicationManager->add(message.getHeaderFrom(),
message.getHeaderTo(),
caller,
subscriptionRequest,
messageSender);
}
} catch (const std::invalid_argument& e) {
JOYNR_LOG_ERROR(
logger,
"Unable to deserialize broadcast subscription request object from: {} - error: {}",
jsonSubscriptionRequest,
e.what());
}
}
示例10: handleReplyReceived
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());
}
示例11: handlePublicationReceived
void Dispatcher::handlePublicationReceived(const JoynrMessage& message)
{
std::string jsonSubscriptionPublication = message.getPayload();
try {
SubscriptionPublication subscriptionPublication =
JsonSerializer::deserialize<SubscriptionPublication>(jsonSubscriptionPublication);
std::string subscriptionId = subscriptionPublication.getSubscriptionId();
assert(subscriptionManager != nullptr);
std::shared_ptr<ISubscriptionCallback> callback =
subscriptionManager->getSubscriptionCallback(subscriptionId);
if (!callback) {
JOYNR_LOG_ERROR(logger,
"Dropping reply for non/no more existing subscription with id = {}",
subscriptionId);
return;
}
subscriptionManager->touchSubscriptionState(subscriptionId);
int typeId = callback->getTypeId();
// Get the publication interpreter - this has to be a reference to support
// PublicationInterpreter polymorphism
IPublicationInterpreter& interpreter =
MetaTypeRegistrar::instance().getPublicationInterpreter(typeId);
interpreter.execute(callback, subscriptionPublication);
} catch (const std::invalid_argument& e) {
JOYNR_LOG_ERROR(
logger,
"Unable to deserialize subscription publication object from: {} - error: {}",
jsonSubscriptionPublication,
e.what());
}
}
示例12: handleBroadcastSubscriptionRequestReceived
void Dispatcher::handleBroadcastSubscriptionRequestReceived(const JoynrMessage& message)
{
LOG_TRACE(logger, "Starting handleBroadcastSubscriptionRequestReceived");
// Make sure that noone is registering a Caller at the moment, because a racing condition could
// occour.
QMutexLocker locker(&subscriptionHandlingMutex);
assert(publicationManager != NULL);
QString receiverId = message.getHeaderTo();
QSharedPointer<RequestCaller> caller = requestCallerDirectory.lookup(receiverId.toStdString());
QByteArray jsonSubscriptionRequest = message.getPayload();
// PublicationManager is responsible for deleting SubscriptionRequests
BroadcastSubscriptionRequest* subscriptionRequest =
JsonSerializer::deserialize<BroadcastSubscriptionRequest>(jsonSubscriptionRequest);
if (subscriptionRequest == Q_NULLPTR) {
LOG_ERROR(logger,
QString("Unable to deserialize broadcast subscription request object from: %1")
.arg(QString::fromUtf8(jsonSubscriptionRequest)));
return;
}
if (caller.isNull()) {
// Provider not registered yet
// Dispatcher will call publicationManger->restore when a new provider is added to activate
// subscriptions for that provider
publicationManager->add(
message.getHeaderFrom(), message.getHeaderTo(), *subscriptionRequest);
} else {
publicationManager->add(message.getHeaderFrom(),
message.getHeaderTo(),
caller,
*subscriptionRequest,
messageSender);
}
delete subscriptionRequest;
}
示例13: handlePublicationReceived
void Dispatcher::handlePublicationReceived(const JoynrMessage& message)
{
QByteArray jsonSubscriptionPublication = message.getPayload();
SubscriptionPublication* subscriptionPublication =
JsonSerializer::deserialize<SubscriptionPublication>(jsonSubscriptionPublication);
if (subscriptionPublication == Q_NULLPTR) {
LOG_ERROR(logger,
QString("Unable to deserialize subscription publication object from: %1")
.arg(QString::fromUtf8(jsonSubscriptionPublication)));
return;
}
QString subscriptionId = subscriptionPublication->getSubscriptionId();
assert(subscriptionManager != NULL);
QSharedPointer<ISubscriptionCallback> callback =
subscriptionManager->getSubscriptionCallback(subscriptionId);
if (callback.isNull()) {
LOG_ERROR(logger,
"Dropping reply for non/no more existing subscription with id=" + subscriptionId);
delete subscriptionPublication;
return;
}
subscriptionManager->touchSubscriptionState(subscriptionId);
int typeId = callback->getTypeId();
// Get the publication interpreter - this has to be a reference to support
// PublicationInterpreter polymorphism
IPublicationInterpreter& interpreter =
MetaTypeRegistrar::instance().getPublicationInterpreter(typeId);
interpreter.execute(callback, *subscriptionPublication);
delete subscriptionPublication;
}
示例14: handleRequestReceived
void Dispatcher::handleRequestReceived(const JoynrMessage& message)
{
std::string senderId = message.getHeaderFrom();
std::string receiverId = message.getHeaderTo();
// json request
// lookup necessary data
std::string jsonRequest = message.getPayload();
std::shared_ptr<RequestCaller> caller = requestCallerDirectory.lookup(receiverId);
if (caller == nullptr) {
JOYNR_LOG_ERROR(
logger,
"caller not found in the RequestCallerDirectory for receiverId {}, ignoring",
receiverId);
return;
}
std::string interfaceName = caller->getInterfaceName();
// Get the request interpreter that has been registered with this interface name
std::shared_ptr<IRequestInterpreter> requestInterpreter =
InterfaceRegistrar::instance().getRequestInterpreter(interfaceName);
// deserialize json
try {
Request request = JsonSerializer::deserialize<Request>(jsonRequest);
std::string requestReplyId = request.getRequestReplyId();
JoynrTimePoint requestExpiryDate = message.getHeaderExpiryDate();
std::function<void(std::vector<Variant>)> onSuccess =
[requestReplyId, requestExpiryDate, this, senderId, receiverId](
std::vector<Variant> returnValueVar) {
Reply reply;
reply.setRequestReplyId(requestReplyId);
reply.setResponse(std::move(returnValueVar));
// send reply back to the original sender (ie. sender and receiver ids are reversed
// on
// purpose)
JOYNR_LOG_DEBUG(logger,
"Got reply from RequestInterpreter for requestReplyId {}",
requestReplyId);
JoynrTimePoint now = std::chrono::time_point_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now());
std::int64_t ttl = std::chrono::duration_cast<std::chrono::milliseconds>(
requestExpiryDate - now).count();
messageSender->sendReply(receiverId, // receiver of the request is sender of reply
senderId, // sender of request is receiver of reply
MessagingQos(ttl),
reply);
};
std::function<void(const exceptions::JoynrException&)> onError =
[requestReplyId, requestExpiryDate, this, senderId, receiverId](
const exceptions::JoynrException& exception) {
Reply reply;
reply.setRequestReplyId(requestReplyId);
reply.setError(joynr::exceptions::JoynrExceptionUtil::createVariant(exception));
JOYNR_LOG_DEBUG(logger,
"Got error reply from RequestInterpreter for requestReplyId {}",
requestReplyId);
JoynrTimePoint now = std::chrono::time_point_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now());
std::int64_t ttl = std::chrono::duration_cast<std::chrono::milliseconds>(
requestExpiryDate - now).count();
messageSender->sendReply(receiverId, // receiver of the request is sender of reply
senderId, // sender of request is receiver of reply
MessagingQos(ttl),
reply);
};
// execute request
requestInterpreter->execute(caller,
request.getMethodName(),
request.getParams(),
request.getParamDatatypes(),
onSuccess,
onError);
} catch (const std::invalid_argument& e) {
JOYNR_LOG_ERROR(logger,
"Unable to deserialize request object from: {} - error: {}",
jsonRequest,
e.what());
return;
}
}
示例15: receive
void Dispatcher::receive(const JoynrMessage& message)
{
JOYNR_LOG_DEBUG(logger, "receive(message). Message payload: {}", message.getPayload());
ReceivedMessageRunnable* receivedMessageRunnable = new ReceivedMessageRunnable(message, *this);
handleReceivedMessageThreadPool.execute(receivedMessageRunnable);
}