summaryrefslogtreecommitdiffstats
path: root/src/plugins/voiceagents
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/voiceagents')
-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;