diff options
author | Scott Murray <scott.murray@konsulko.com> | 2020-01-02 16:06:31 -0500 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2020-01-02 16:16:07 -0500 |
commit | a10448fa4784c2f88937db2e7fe341cf8f832647 (patch) | |
tree | 707481d2521e29c75b16025a74008912d58115a1 /src/plugins/voiceagents | |
parent | 5279260ee250060b86212e41fe2522db9bcb173d (diff) |
Fix event argument populationhalibut_8.0.6halibut_8.0.5halibut/8.0.6halibut/8.0.58.0.68.0.5halibut
Forwarded events from voiceagents have their argument JSON as a whole
stuck into a json-c string object which is then used as the outgoing
event argument. The effect is the whole argument JSON is quoted and
unusable until run through a JSON parser on the receiver side. This is
contrary to the vshl-core event documentation and inconvenient for
client implementors, so fix it by tokenizing the internal JSON string
into a json_object tree and passing that as the event argument.
Bug-AGL: SPEC-3084
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: If6a80de68c7932742b7cb83d5b128d5458d5e049
Diffstat (limited to 'src/plugins/voiceagents')
-rw-r--r-- | src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp b/src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp index 3b55505..bff9d8c 100644 --- a/src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp +++ b/src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp @@ -14,6 +14,8 @@ */ #include "voiceagents/include/VoiceAgentEventsHandler.h" +#include <json-c/json.h> + static string TAG = "vshlcore::voiceagents::VoiceAgentEventsHandler"; static string VA_VERB_SUBSCRIBE = "subscribe"; @@ -101,7 +103,17 @@ bool VoiceAgentEventsHandler::onIncomingEvent(const string eventName, const stri string eventNameWithVAId = createEventNameWithVAId(eventName, voiceAgentId); auto it = mEventsMap.find(eventNameWithVAId); if (it != mEventsMap.end()) { - return it->second->publishEvent(json_object_new_string(payload.c_str())); + json_object* payloadJ = NULL; + if(payload.length()) { + payloadJ = json_tokener_parse(payload.c_str()); + } else { + payloadJ = json_object_new_string(""); + } + if(!payloadJ) { + mLogger->log(Level::ERROR, TAG, "Unable to parse payload JSON: " + payload); + return false; + } + return it->second->publishEvent(payloadJ); } return true; |