AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Public Member Functions | List of all members
alexaClientSDK::adsl::DirectiveProcessor Class Reference

#include <DirectiveProcessor.h>

Public Member Functions

 DirectiveProcessor (DirectiveRouter *directiveRouter)
 
 ~DirectiveProcessor ()
 
void setDialogRequestId (const std::string &dialogRequestId)
 
std::string getDialogRequestId ()
 
bool onDirective (std::shared_ptr< avsCommon::avs::AVSDirective > directive)
 
void shutdown ()
 
void disable ()
 
bool enable ()
 

Detailed Description

Object to process AVSDirectives that have a non-empty dialogRequestId.

DirectiveProcessor receives directives via its onDirective() method. The dialogRequestId property of incoming directives is checked against the current dialogRequestId (which is set by setDialogRequestId()). If the AVSDirective's value is not empty and does not match, the AVSDirective is dropped, and onDirective() returns true to indicate that the AVSDirective has been consumed (in this case, because it is not longer relevant).
After passing this hurdle, the AVSDirective is forwarded to the preHandleDirective() method of whichever DirectiveHandler is registered to handle the AVSDirective. If no DirectiveHandler is registered, the incoming directive is rejected and any directives with the same dialogRequestId that are already queued for handling by the DirectiveProcessor are canceled (because an entire dialog is canceled when the handling of any of its directives fails), and onDirective() returns false to indicate that the unhandled AVDirective was rejected.
Once an AVSDirective has been successfully forwarded for preHandling, it is enqueued awaiting its turn to be handled. Handling is accomplished by forwarding the AVSDirective to the handleDirective() method of whichever DirectiveHandler is registered to handle the AVSDirective. The handling of an AVSDirective can be configured as BLOCKING or NON_BLOCKING. If the directive at the head of the handling queue is configured for BLOCKING, the handling of subsequent AVSDirectives is held up until the DirectiveHandler for the BLOCKING AVSDirective indicates that handling has completed or failed. Otherwise handleDirective() is invoked, the AVSDirective is popped from the front of the queue, and processing of queued AVSDirective's continues.

Constructor & Destructor Documentation

◆ DirectiveProcessor()

alexaClientSDK::adsl::DirectiveProcessor::DirectiveProcessor ( DirectiveRouter directiveRouter)

Constructor.

Parameters
directiveRouterAn object used to route directives to their registered handler.

◆ ~DirectiveProcessor()

alexaClientSDK::adsl::DirectiveProcessor::~DirectiveProcessor ( )

Destructor.

Member Function Documentation

◆ disable()

void alexaClientSDK::adsl::DirectiveProcessor::disable ( )

Disable the DirectiveProcessor, queues all outstanding AVSDirectives for cancellation and blocks until the processing of all AVSDirectives has completed.

◆ enable()

bool alexaClientSDK::adsl::DirectiveProcessor::enable ( )

Enable the DirectiveProcessor.

Returns
Whether it succeeded to enable the directive processor.

◆ getDialogRequestId()

std::string alexaClientSDK::adsl::DirectiveProcessor::getDialogRequestId ( )

Returns the dialogRequestId currently in use for Directive handling. This may be the empty string if Directives have either experienced errors, or have been cancelled.

Returns
dialogRequestId The current dialog request id.

◆ onDirective()

bool alexaClientSDK::adsl::DirectiveProcessor::onDirective ( std::shared_ptr< avsCommon::avs::AVSDirective directive)

Queue an AVSDirective for handling by whatever DirectiveHandler was registered to handle it.

Parameters
directiveThe AVADirective to process.
Returns
Whether the directive was consumed.

◆ setDialogRequestId()

void alexaClientSDK::adsl::DirectiveProcessor::setDialogRequestId ( const std::string &  dialogRequestId)

Set the current dialogRequestId. If a new value is specified any AVSDirective's whose pre-handling or handling is already in progress the directive will be cancelled.

Parameters
dialogRequestIdThe new value for the current dialogRequestId.

◆ shutdown()

void alexaClientSDK::adsl::DirectiveProcessor::shutdown ( )

Shut down the DirectiveProcessor. This queues all outstanding AVSDirectives for cancellation and blocks until the processing of all AVSDirectives has completed.


The documentation for this class was generated from the following file:

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0