AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
IPCRouter.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_IPC_IPCROUTER_H_
17 #define ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_IPC_IPCROUTER_H_
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 #include <unordered_map>
23 
27 
30 
35 
36 namespace alexaClientSDK {
37 namespace sampleApplications {
38 namespace ipcServerSampleApp {
39 namespace ipc {
40 
55 class IPCRouter
58 public:
67  static std::shared_ptr<IPCRouter> create(
68  std::shared_ptr<communication::MessagingServerInterface> messagingServer,
69  std::shared_ptr<IPCDispatcherInterface> ipcDispatcher,
70  std::shared_ptr<IPCVersionManager> ipcVersionManager);
71 
78  void onMessage(const std::string& message);
79 
82  std::shared_ptr<IPCDispatcherInterface> registerHandler(
83  const std::string& ipcNamespace,
84  std::weak_ptr<IPCHandlerBase> handler) override;
85  bool deregisterHandler(const std::string& ipcNamespace) override;
87 
90  void doShutdown() override;
92 
93 private:
95  struct HandlerInstance {
96  const std::string& ipcNamespace;
97  std::weak_ptr<IPCHandlerBase> handler;
98  };
99 
107  IPCRouter(
108  std::shared_ptr<communication::MessagingServerInterface> messagingServer,
109  std::shared_ptr<IPCDispatcherInterface> ipcDispatcher,
110  const std::shared_ptr<IPCVersionManager> ipcVersionManager);
111 
119  std::shared_ptr<IPCHandlerBase> getHandlerRegisteredLocked(const std::string& ipcNamespace);
120 
122  std::unordered_map<std::string, HandlerInstance> m_handlerMap;
123 
125  std::shared_ptr<communication::MessagingServerInterface> m_messagingServer;
126 
128  std::shared_ptr<communication::MessageListenerInterface> m_messageListener;
129 
131  std::shared_ptr<IPCVersionManager> m_ipcVersionManager;
132 
134  std::shared_ptr<IPCDispatcherInterface> m_ipcDispatcher;
135 
137  std::mutex m_mutex;
138 };
139 
140 } // namespace ipc
141 } // namespace ipcServerSampleApp
142 } // namespace sampleApplications
143 } // namespace alexaClientSDK
144 
145 #endif // ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_IPC_IPCROUTER_H_
bool deregisterHandler(const std::string &ipcNamespace) override
::std::string string
Definition: gtest-port.h:1097
std::shared_ptr< IPCDispatcherInterface > registerHandler(const std::string &ipcNamespace, std::weak_ptr< IPCHandlerBase > handler) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
static std::shared_ptr< IPCRouter > create(std::shared_ptr< communication::MessagingServerInterface > messagingServer, std::shared_ptr< IPCDispatcherInterface > ipcDispatcher, std::shared_ptr< IPCVersionManager > ipcVersionManager)
tuple message
Definition: gtest_output_test.py:331

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