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

#include <IPCRouter.h>

Inheritance diagram for alexaClientSDK::sampleApplications::ipcServerSampleApp::ipc::IPCRouter:
Inheritance graph
Collaboration diagram for alexaClientSDK::sampleApplications::ipcServerSampleApp::ipc::IPCRouter:
Collaboration graph

Public Member Functions

void onMessage (const std::string &message)
IPCHandlerRegistrationInterface Functions
std::shared_ptr< IPCDispatcherInterfaceregisterHandler (const std::string &ipcNamespace, std::weak_ptr< IPCHandlerBase > handler) override
bool deregisterHandler (const std::string &ipcNamespace) override
RequiresShutdown Functions
void doShutdown () override
- Public Member Functions inherited from alexaClientSDK::sampleApplications::ipcServerSampleApp::ipc::IPCHandlerRegistrationInterface
virtual ~IPCHandlerRegistrationInterface ()=default
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::RequiresShutdown
 RequiresShutdown (const std::string &name)
virtual ~RequiresShutdown ()
 Destructor. More...
const std::string & name () const
void shutdown ()
bool isShutdown () const

Static Public Member Functions

static std::shared_ptr< IPCRoutercreate (std::shared_ptr< communication::MessagingServerInterface > messagingServer, std::shared_ptr< IPCDispatcherInterface > ipcDispatcher, std::shared_ptr< IPCVersionManager > ipcVersionManager)

Additional Inherited Members

Detailed Description

The function of this class is responsible for managing the messages to and from IPC client. Following are the rules:

  1. On initialization, router will register IPC messaging contracts used for sending and receiving messages over IPC.
  2. Router will also register all the feature IPC handlers that implements IPC channel for their respective namespaces. It can de-register the IPC components.
  3. While registered, router will provide a concrete ipc dispatcher (implemented by self).
  4. When router receives a message, it sniffs the namespace from header and passes on the payload/message to the handler and request to invokeMethod. Note that access to handler component registry is time-bound and thread-safe. To accommodate these attributes, this class deliberately avoids executor pattern and instead relies on mutex lock to minimize the critical section.
  5. When handler gets a message that needs to be communicated over IPC, router constructs appropriate message and dispatches.

Member Function Documentation

◆ create()

static std::shared_ptr<IPCRouter> alexaClientSDK::sampleApplications::ipcServerSampleApp::ipc::IPCRouter::create ( std::shared_ptr< communication::MessagingServerInterface messagingServer,
std::shared_ptr< IPCDispatcherInterface ipcDispatcher,
std::shared_ptr< IPCVersionManager ipcVersionManager 

Constructs an instance of an IPC Router.

messagingServerAn implementation of MessagingServerInterface.
ipcDispatcherAn instance of a message dispatcher to IPC Client.
ipcVersionManagerAn instance of a IPCVersionManager.
an instance of IPCRouter.

◆ deregisterHandler()

bool alexaClientSDK::sampleApplications::ipcServerSampleApp::ipc::IPCRouter::deregisterHandler ( const std::string &  ipcNamespace)

De-registers a IPC handler interface for a given namespace

ipcNamespaceNamespace for the IPC handler to be de-registered.
true if successful.

Implements alexaClientSDK::sampleApplications::ipcServerSampleApp::ipc::IPCHandlerRegistrationInterface.

◆ doShutdown()

void alexaClientSDK::sampleApplications::ipcServerSampleApp::ipc::IPCRouter::doShutdown ( )

Prepares/enables this object to be deleted. This should be the last function called on this object prior to deleting (or resetting) its shared_ptr.

  • Attempting to call functions on this object after calling shutdown() can result in undefined behavior.
  • Neglecting to call shutdown() on this object can result in resource leaks or other undefined behavior.

Implements alexaClientSDK::avsCommon::utils::RequiresShutdown.

◆ onMessage()

void alexaClientSDK::sampleApplications::ipcServerSampleApp::ipc::IPCRouter::onMessage ( const std::string &  message)

Called when a new message needs to be routed to registered ipc component.

Blocking in this handler will block delivery of further messages.
messagea serialized message that needs to be routed to respective IPC component.

◆ registerHandler()

std::shared_ptr<IPCDispatcherInterface> alexaClientSDK::sampleApplications::ipcServerSampleApp::ipc::IPCRouter::registerHandler ( const std::string &  ipcNamespace,
std::weak_ptr< IPCHandlerBase handler 

Registers a IPC handler interface for a given namespace

ipcNamespaceNamespace for the IPC handler to be registered.
handlerA weak pointer to the handler instance.
an instance of Dispatcher used to sending message over IPC channel.

Implements alexaClientSDK::sampleApplications::ipcServerSampleApp::ipc::IPCHandlerRegistrationInterface.

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

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