diff options
Diffstat (limited to 'src/plugins/core/src')
-rw-r--r-- | src/plugins/core/src/VRRequestImpl.cpp | 16 | ||||
-rw-r--r-- | src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp | 26 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/plugins/core/src/VRRequestImpl.cpp b/src/plugins/core/src/VRRequestImpl.cpp index 63302d8..d1a18ac 100644 --- a/src/plugins/core/src/VRRequestImpl.cpp +++ b/src/plugins/core/src/VRRequestImpl.cpp @@ -32,6 +32,7 @@ namespace core { string VRRequest::VA_VERB_STARTLISTENING = "startListening"; string VRRequest::VA_VERB_CANCEL = "cancel"; +string VRRequest::VA_VERB_SUBSCRIBETOCBLEVENTS = "subscribeToCBLEvents"; unique_ptr<VRRequest> VRRequest::create( shared_ptr<vshlcore::common::interfaces::ILogger> logger, @@ -76,6 +77,21 @@ bool VRRequest::startListening() { return true; } + bool VRRequest::subscribeToLoginEvents(std::list<std::string> *args) { + json_object* argsJ = json_object_new_object(); + json_object* evJ = json_object_new_array(); + json_object* resultJ; + std::string error, info; + bool result = true; + + json_object_object_add(argsJ, "events", evJ); + int rc = mApi->callSync(mVoiceAgent->getApi(), VA_VERB_SUBSCRIBETOCBLEVENTS, argsJ, &resultJ, error, info); + + FREEIF(resultJ); + + return true; +} + bool VRRequest::cancel() { json_object* object = NULL; std::string error, info; diff --git a/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp b/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp index 78ef10a..57fc592 100644 --- a/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp +++ b/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp @@ -62,6 +62,32 @@ string VRRequestProcessorDelegate::startRequestForVoiceAgent( return newReqId; } +string VRRequestProcessorDelegate::loginEventsRequestForVoiceAgent( + shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent, + std::list<std::string> *args) { + if (!mApi) { + mLogger->log(Level::ERROR, TAG, "Failed to loginEventsRequestForVoiceAgent: " + voiceAgent->getId() + ", No API."); + return ""; + } + + // Generate a new request ID. + string newReqId = vshlcore::utilities::uuid::generateUUID(); + + // Create a new request and start listening. + shared_ptr<VRRequest> newRequest = VRRequest::create(mLogger, mApi, newReqId, voiceAgent); + + mLogger->log(Level::DEBUG, TAG, "Starting login request with ID: " + newReqId); + if (!newRequest->subscribeToLoginEvents(args)) { + mLogger->log(Level::ERROR, TAG, "Failed to subscribe to login events."); + return ""; + } + + // Insert only if its started successfully. + mVRRequests.insert(make_pair(voiceAgent->getId(), newRequest)); + + return newReqId; +} + void VRRequestProcessorDelegate::cancelAllRequests() { // Cancel Pending requests if (!mVRRequests.empty()) { |