summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2020-01-02 16:06:31 -0500
committerScott Murray <scott.murray@konsulko.com>2020-01-03 15:52:14 +0000
commitb2c24e2bff2873acbd39c7a513cea98962390350 (patch)
tree3840ba8c8898b3cf89fa27fae2448a56631d3236 /src
parentdc5104d4254c9789a9b1ebce4543f0558e56aaac (diff)
Fix event argument populationicefish_8.99.5icefish/8.99.58.99.5
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 (cherry picked from commit a10448fa4784c2f88937db2e7fe341cf8f832647)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp14
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;