AWS IoT C++ SDK
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
awsiotsdk::ClientCore Class Reference

Client Core Class. More...

#include <ClientCore.hpp>

Public Member Functions

 ClientCore (const ClientCore &)=delete
 
 ClientCore (ClientCore &&)=delete
 
ClientCoreoperator= (const ClientCore &) &=delete
 
ClientCoreoperator= (ClientCore &&) &=delete
 
void SetProcessQueuedActions (bool process_queued_actions)
 Enable/Disable processing of queued actions. More...
 
ResponseCode RegisterAction (ActionType action_type, Action::CreateHandlerPtr p_action_create_handler)
 Register Action for execution by Client Core. More...
 
ResponseCode PerformAction (ActionType action_type, std::shared_ptr< ActionData > action_data, std::chrono::milliseconds action_reponse_timeout)
 Perform Action in Blocking Mode. More...
 
ResponseCode PerformActionAsync (ActionType action_type, std::shared_ptr< ActionData > action_data, uint16_t &action_id_out)
 Perform Action in Asynchronous Mode. More...
 
ResponseCode CreateActionRunner (ActionType action_type, std::shared_ptr< ActionData > action_data)
 Create Thread Task to execute request Action Type. More...
 
void GracefulShutdownAllThreadTasks ()
 Waits for all threads to complete their tasks and then clears them. More...
 

Static Public Member Functions

static std::unique_ptr< ClientCoreCreate (std::shared_ptr< NetworkConnection > p_network_connection, std::shared_ptr< ClientCoreState > p_state)
 Factory method for creating a Client Core instance. More...
 

Protected Member Functions

 ClientCore (std::shared_ptr< NetworkConnection > p_network_connection, std::shared_ptr< ClientCoreState > p_state)
 Constructor. More...
 

Protected Attributes

util::Map< ActionType, std::shared_ptr< util::Threading::ThreadTask > > thread_map_
 Map for storing currently active threads.
 
std::shared_ptr< ClientCoreStatep_client_core_state_
 Client Core state instance.
 

Detailed Description

Defining a class for the Core Client. This class is responsible for performing both Sync and Async actions It contains the action queue, an action registry and a map to keep track of running threads It also keeps track of the Common Action State as well as the Network connection

Constructor & Destructor Documentation

◆ ClientCore()

awsiotsdk::ClientCore::ClientCore ( std::shared_ptr< NetworkConnection p_network_connection,
std::shared_ptr< ClientCoreState p_state 
)
protected
Parameters
p_network_connection- Network Connection instance to be passed as argument to actions
p_state- Client Core state instance

Member Function Documentation

◆ Create()

std::unique_ptr< ClientCore > awsiotsdk::ClientCore::Create ( std::shared_ptr< NetworkConnection p_network_connection,
std::shared_ptr< ClientCoreState p_state 
)
static
Parameters
p_network_connection- Network Connection instance to be passed as argument to actions
p_state- Client Core state instance
Returns
std::unique_ptr<ClientCore> instance

◆ CreateActionRunner()

ResponseCode awsiotsdk::ClientCore::CreateActionRunner ( ActionType  action_type,
std::shared_ptr< ActionData action_data 
)

This API will create a new instance of the Action Type that is request in the API call and call perform action on that instance in a new Thread Task. If the Action is Thread Aware, it will be executed until it finishes or the Thread Task is terminated (Usually on exit).

Parameters
action_type- Type of the Action to be executed. Must be registered
action_data- Action Data to be passed as argument to the Action instance
Returns
ResponseCode indicating result of the API call

◆ GracefulShutdownAllThreadTasks()

void awsiotsdk::ClientCore::GracefulShutdownAllThreadTasks ( )

This API will go through all the active Thread Tasks and waits for them to complete their respective tasks. The completed Thread Task is then cleared.

◆ PerformAction()

ResponseCode awsiotsdk::ClientCore::PerformAction ( ActionType  action_type,
std::shared_ptr< ActionData action_data,
std::chrono::milliseconds  action_reponse_timeout 
)

This API will perform the Action in Blocking mode. The timeout for the action to give a valid response is provided as an argument. This API stops processing of all outbound actions until Response is received for the requested Action Type

Parameters
action_type- Type of the Action to be executed. Must be registered
action_data- Action Data to be passed as argument to the Action instance
action_reponse_timeout- Timeout for this API call
Returns
ResponseCode indicating result of the API call

◆ PerformActionAsync()

ResponseCode awsiotsdk::ClientCore::PerformActionAsync ( ActionType  action_type,
std::shared_ptr< ActionData action_data,
uint16_t &  action_id_out 
)

This API will enqueue the the Action to be performed Asynchronously. If an Async Ack Handler is provided in the Action data, and the Action expects to receive an Ack, the calling Action will be notified using Action ID and Response Code. This API returns Action ID as an out parameter

Parameters
action_type- Type of the Action to be executed. Must be registered
action_data- Action Data to be passed as argument to the Action instance
[out]action_id_out- Action ID assigned to this request
Returns
ResponseCode indicating result of the enqueue operation

◆ RegisterAction()

ResponseCode awsiotsdk::ClientCore::RegisterAction ( ActionType  action_type,
Action::CreateHandlerPtr  p_action_create_handler 
)

This function allows Actions to be registered to be executed at a later stage by Client Core. Actions must be registered before PerformAction can be called using the Action Type. This also applies to Creating Action runners which allow running Actions in dedicated Thread Tasks. Only one Action can be registered to each Action Type. If a second call is made with the same Action Type, the previous registration will be overwritten

Parameters
action_type- Type of the Action that will be creating using the provided handler
p_action_create_handler- Factory method pointer which returns an Action instance
Returns
ResponseCode indicating result of the API call

◆ SetProcessQueuedActions()

void awsiotsdk::ClientCore::SetProcessQueuedActions ( bool  process_queued_actions)
inline
Parameters
process_queued_actions- boolean value indicating new state