summaryrefslogtreecommitdiffstats
path: root/src/plugins/voiceagents
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/voiceagents')
-rw-r--r--src/plugins/voiceagents/VoiceAgentEventNames.h5
-rw-r--r--src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp14
2 files changed, 17 insertions, 2 deletions
diff --git a/src/plugins/voiceagents/VoiceAgentEventNames.h b/src/plugins/voiceagents/VoiceAgentEventNames.h
index 92cc8dc..abee50a 100644
--- a/src/plugins/voiceagents/VoiceAgentEventNames.h
+++ b/src/plugins/voiceagents/VoiceAgentEventNames.h
@@ -25,10 +25,13 @@ namespace voiceagents {
static string VSHL_EVENT_AUTH_STATE_EVENT = "voice_authstate_event";
static string VSHL_EVENT_CONNECTION_STATE_EVENT = "voice_connectionstate_event";
static string VSHL_EVENT_DIALOG_STATE_EVENT = "voice_dialogstate_event";
+static string VSHL_EVENT_LOGINPAIR_RECEIVED_EVENT = "voice_cbl_codepair_received_event";
+static string VSHL_EVENT_LOGINPAIR_EXPIRED_EVENT = "voice_cbl_codepair_expired_event";
static list<string> VSHL_EVENTS = {
VSHL_EVENT_AUTH_STATE_EVENT, VSHL_EVENT_CONNECTION_STATE_EVENT,
- VSHL_EVENT_DIALOG_STATE_EVENT,
+ VSHL_EVENT_DIALOG_STATE_EVENT, VSHL_EVENT_LOGINPAIR_RECEIVED_EVENT,
+ VSHL_EVENT_LOGINPAIR_EXPIRED_EVENT,
};
} // namespace voiceagents
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;