AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
APLDocumentSessionManager.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_ALEXAPRESENTATION_APLDOCUMENTSESSIONMANAGER_H_
17 #define ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_ALEXAPRESENTATION_APLDOCUMENTSESSIONMANAGER_H_
18 
19 #include <unordered_map>
20 
22 
23 namespace alexaClientSDK {
24 namespace sampleApplications {
25 namespace ipcServerSampleApp {
26 
28 public:
33  static std::unique_ptr<APLDocumentSessionManager> create();
34 
37  void addDocumentSession(
38  const aplCapabilityCommonInterfaces::PresentationSession& presentationSession,
39  const std::string& token,
40  std::shared_ptr<aplCapabilityCommonInterfaces::APLDocumentSessionInterface> session) override;
41  std::shared_ptr<aplCapabilityCommonInterfaces::APLDocumentSessionInterface> getDocumentSessionByPresentationSession(
42  const aplCapabilityCommonInterfaces::PresentationSession& presentationSessionId) override;
43  std::shared_ptr<aplCapabilityCommonInterfaces::APLDocumentSessionInterface> getDocumentSessionByToken(
44  const std::string& token) override;
45  void clearDocumentSession(const aplCapabilityCommonInterfaces::PresentationSession& presentationSession) override;
47  std::function<void(const std::shared_ptr<aplCapabilityCommonInterfaces::APLDocumentSessionInterface>&)> func)
48  override;
50  const aplCapabilityCommonInterfaces::PresentationSession& presentationSession,
51  const std::string& token) override;
53 
54 private:
59 
66  std::shared_ptr<aplCapabilityCommonInterfaces::APLDocumentSessionInterface> findSessionByTokenLocked(
67  const std::string& token);
68 
74  std::string generatePresentationId(
75  const aplCapabilityCommonInterfaces::PresentationSession& presentationSession) const;
76 
78  std::mutex m_mutex;
79 
81  std::unordered_map<std::string, std::string> m_tokenToPresentationSessionId;
82 
84  std::unordered_map<std::string, std::set<std::string>> m_presentationSessionIdToToken;
85 
87  std::unordered_map<std::string, std::shared_ptr<aplCapabilityCommonInterfaces::APLDocumentSessionInterface>>
88  m_activeSessions;
89 };
90 } // namespace ipcServerSampleApp
91 } // namespace sampleApplications
92 } // namespace alexaClientSDK
93 
94 #endif // ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_ALEXAPRESENTATION_APLDOCUMENTSESSIONMANAGER_H_
::std::string string
Definition: gtest-port.h:1097
void invokeFunctionPerDocumentSession(std::function< void(const std::shared_ptr< aplCapabilityCommonInterfaces::APLDocumentSessionInterface > &)> func) override
void addDocumentSession(const aplCapabilityCommonInterfaces::PresentationSession &presentationSession, const std::string &token, std::shared_ptr< aplCapabilityCommonInterfaces::APLDocumentSessionInterface > session) override
void associateTokenWithPresentationSession(const aplCapabilityCommonInterfaces::PresentationSession &presentationSession, const std::string &token) override
void clearDocumentSession(const aplCapabilityCommonInterfaces::PresentationSession &presentationSession) override
std::shared_ptr< aplCapabilityCommonInterfaces::APLDocumentSessionInterface > getDocumentSessionByPresentationSession(const aplCapabilityCommonInterfaces::PresentationSession &presentationSessionId) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
static std::unique_ptr< APLDocumentSessionManager > create()
std::shared_ptr< aplCapabilityCommonInterfaces::APLDocumentSessionInterface > getDocumentSessionByToken(const std::string &token) override

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