16 #ifndef ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_GUI_GUICLIENT_H_ 17 #define ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_GUI_GUICLIENT_H_ 21 #include <condition_variable> 27 #include <rapidjson/document.h> 67 namespace sampleApplications {
68 namespace ipcServerSampleApp {
84 ,
public std::enable_shared_from_this<GUIClient>
100 static std::shared_ptr<GUIClient>
create(
101 std::shared_ptr<MessagingServerInterface> serverImplementation,
102 const std::shared_ptr<registrationManager::CustomerDataManagerInterface> customerDataManager,
103 const std::shared_ptr<ipc::IPCVersionManager> ipcVersionManager,
104 std::shared_ptr<avsCommon::utils::DeviceInfo> deviceInfo);
108 void setGUIManager(std::shared_ptr<gui::GUIServerInterface> guiManager)
override;
113 std::shared_ptr<avsCommon::sdkInterfaces::ChannelObserverInterface> channelObserver)
override;
117 std::shared_ptr<avsCommon::sdkInterfaces::ChannelObserverInterface> channelObserver)
override;
119 void sendCallStateInfo(
140 std::shared_ptr<ipc::IPCRouter>
getIPCRouter()
override;
145 bool start()
override;
147 void setMessageListener(std::shared_ptr<MessageListenerInterface> messageListener)
override;
148 void stop()
override;
150 void setObserver(
const std::shared_ptr<communication::MessagingServerObserverInterface>& observer)
override;
174 const std::vector<avsCommon::sdkInterfaces::endpoints::EndpointIdentifier>& addedOrUpdatedEndpoints,
175 const std::vector<avsCommon::sdkInterfaces::endpoints::EndpointIdentifier>& deletedEndpoints)
override;
231 void setAplClientBridge(std::shared_ptr<AplClientBridge> aplClientBridge,
bool aplVersionChanged);
238 const std::shared_ptr<APLRuntimePresentationAdapter>& aplRuntimePresentationAdapter);
243 const std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface>& mediaPlayer);
283 void doShutdown()
override;
302 std::shared_ptr<GUIClient> focusBridge,
318 std::shared_ptr<GUIClient> m_focusBridge;
328 std::shared_ptr<MessagingServerInterface> serverImplementation,
329 const std::shared_ptr<registrationManager::CustomerDataManagerInterface>& customerDataManager,
330 std::shared_ptr<ipc::IPCVersionManager> ipcVersionManager,
331 std::shared_ptr<avsCommon::utils::DeviceInfo> deviceInfo);
337 void sendInitRequestAndWait();
343 void executeSendCallStateInfo(
353 void executeSendFocusResponse(
const GUIToken token,
const bool result);
393 void executeWriteMessage(
const std::string& payload);
402 bool executeAcquireFocus(
406 std::shared_ptr<avsCommon::sdkInterfaces::ChannelObserverInterface> channelObserver);
414 bool executeReleaseFocus(
417 std::shared_ptr<avsCommon::sdkInterfaces::ChannelObserverInterface> channelObserver);
422 void registerNamespaces();
428 void executeHandleAcceptCall(rapidjson::Document& payload);
434 void executeHandleStopCall(rapidjson::Document& payload);
440 void executeHandleEnableLocalVideo(rapidjson::Document& payload);
446 void executeHandleDisableLocalVideo(rapidjson::Document& payload);
453 void executeHandleSendDtmf(rapidjson::Document& payload);
464 std::shared_ptr<gui::GUIServerInterface> m_guiManager;
470 std::shared_ptr<MessagingServerInterface> m_serverImplementation;
473 std::thread m_serverThread;
476 std::thread m_initThread;
482 std::condition_variable m_cond;
485 std::atomic_bool m_hasServerStarted;
488 std::atomic_bool m_initMessageReceived;
491 std::atomic_bool m_errorState;
494 std::shared_ptr<MessageListenerInterface> m_messageListener;
497 std::atomic_bool m_shouldRestart;
500 std::shared_ptr<communication::MessagingServerObserverInterface> m_observer;
503 std::shared_ptr<AplClientBridge> m_aplClientBridge;
506 std::shared_ptr<ipc::IPCVersionManager> m_ipcVersionManager;
510 std::atomic_bool m_limitedInteraction;
513 std::map<std::string, std::function<void(rapidjson::Document&)>> m_messageHandlers;
516 std::mutex m_mapMutex;
519 std::map<GUIToken, std::shared_ptr<avsCommon::sdkInterfaces::ChannelObserverInterface>> m_focusObservers;
522 std::map<GUIToken, std::shared_ptr<avsCommon::utils::timing::Timer>> m_autoReleaseTimers;
525 std::shared_ptr<ipc::AudioFocusManagerHandler> m_audioFocusManagerIPCHandler;
528 std::shared_ptr<ipc::SystemHandler> m_systemIPCHandler;
531 std::map<std::string, std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface>> m_mediaPlayerMap;
534 std::shared_ptr<APLRuntimePresentationAdapter> m_aplRuntimePresentationAdapter;
537 std::shared_ptr<ipc::IPCRouter> m_ipcRouter;
540 std::shared_ptr<IPCAPLAgent> m_ipcAPLAgent;
543 std::shared_ptr<avsCommon::utils::DeviceInfo> m_deviceInfo;
569 #endif // ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_GUI_GUICLIENT_H_
const std::string & name() const
bool dispatch(const std::string &message) override
Definition: MessagingServerInterface.h:34
MixingBehavior
Definition: MixingBehavior.h:25
void focusReleaseRequest(const GUIToken token, const std::string &avsInterface, const std::string &channelName) override
Internal function to execute.
void notifyAuthorizationStateChange(avsCommon::sdkInterfaces::AuthObserverInterface::State state) override
void handleDisplayMetrics(rapidjson::Document &payload) override
void handleLocalClearDocument(rapidjson::Document &payload) override
void focusChangedReport(const std::string &message) override
void setLocales(const std::string &localeStr) override
bool acquireFocus(std::string avsInterface, std::string channelName, avsCommon::avs::ContentType contentType, std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > channelObserver) override
Definition: UIAuthNotifierInterface.h:28
void sendSetLocalesMessage(const std::string &localeStr)
bool releaseFocus(std::string avsInterface, std::string channelName, std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > channelObserver) override
::std::string string
Definition: gtest-port.h:1097
void handleLocalRenderDocument(rapidjson::Document &payload) override
void handleOnFocusChangedReceivedConfirmation(GUIToken token) override
std::shared_ptr< ipc::IPCRouter > getIPCRouter() override
Returns a reference to m_ipcRouter.
Single-thread executor implementation.
Definition: Executor.h:45
void handleRenderComplete(rapidjson::Document &payload) override
State
The enum State describes the state of authorization.
Definition: AuthObserverInterface.h:34
Error
The enum Error encodes possible errors which may occur when changing state.
Definition: CapabilitiesDelegateObserverInterface.h:44
void localesRequest(const std::string &message) override
}
Definition: RequiresShutdown.h:32
void alexaStateRequest(const std::string &message) override
}
Definition: UIStateAggregatorInterface.h:27
Definition: GUIClientInterface.h:43
void notifyAlexaState(const std::string &state) override
FocusState
Definition: FocusState.h:29
void onAuthStateChange(AuthObserverInterface::State newState, AuthObserverInterface::Error newError) override
Definition: AudioFocusManagerHandlerInterface.h:41
bool finalizeClientInitialization(bool errorState) override
void acquireChannelRequest(const std::string &message) override
SampleAppReturnCode run()
Definition: GUIClient.h:74
void onConnectionOpened() override
Definition: AuthObserverInterface.h:31
static std::shared_ptr< GUIClient > create(std::shared_ptr< MessagingServerInterface > serverImplementation, const std::shared_ptr< registrationManager::CustomerDataManagerInterface > customerDataManager, const std::shared_ptr< ipc::IPCVersionManager > ipcVersionManager, std::shared_ptr< avsCommon::utils::DeviceInfo > deviceInfo)
void initIPCRouter()
Initializes the IPC router.
Definition: CapabilitiesDelegateObserverInterface.h:29
void onConnectionClosed() override
void setAPLRuntimePresentationAdapter(const std::shared_ptr< APLRuntimePresentationAdapter > &aplRuntimePresentationAdapter)
void onCapabilitiesStateChange(avsCommon::sdkInterfaces::CapabilitiesObserverInterface::State newState, avsCommon::sdkInterfaces::CapabilitiesObserverInterface::Error newError, const std::vector< avsCommon::sdkInterfaces::endpoints::EndpointIdentifier > &addedOrUpdatedEndpoints, const std::vector< avsCommon::sdkInterfaces::endpoints::EndpointIdentifier > &deletedEndpoints) override
An struct containing call state information.
Definition: CallStateObserverInterface.h:45
void clearData() override
State
The enum State describes the state of the CapabilitiesDelegate.
Definition: CapabilitiesDelegateObserverInterface.h:32
void setGUIManager(std::shared_ptr< gui::GUIServerInterface > guiManager) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void handleAplEvent(rapidjson::Document &payload) override
Definition: MessageInterface.h:54
SampleAppReturnCode
Definition: SampleApplicationReturnCodes.h:25
void sendSetAuthorizationStateMessage(const std::string &state)
Definition: IPCDispatcherInterface.h:29
Definition: ChannelObserverInterface.h:29
ContentType
Definition: ContentType.h:25
Definition: SystemHandlerInterface.h:29
Definition: MessageListenerInterface.h:29
void writeMessage(const std::string &payload) override
void onMessage(const std::string &jsonMessage) override
void sendMessage(messages::MessageInterface &message) override
void authorizationStateRequest(const std::string &message) override
}
void focusAcquireRequest(const GUIToken token, const std::string &avsInterface, const std::string &channelName, avsCommon::avs::ContentType contentType) override
Internal function to execute.
Definition: RegistrationObserverInterface.h:24
void setAplClientBridge(std::shared_ptr< AplClientBridge > aplClientBridge, bool aplVersionChanged)
}
State
Definition: State.h:35
void authorizationInfoRequest(const std::string &message) override
}
void releaseChannelRequest(const std::string &message) override
void handleLocalExecuteCommands(rapidjson::Document &payload) override
void sendSetAlexaStateMessage(const std::string &state)
uint64_t GUIToken
Alias for GUI provided token.
Definition: GUIClientInterface.h:46
void addToMediaPlayerMap(const std::string &name, const std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerInterface > &mediaPlayer)
Adds a mediaplayer to the m_mediaPlayerMap with the key as the name and value as the mediaplayer...
Definition: MessagingServerObserverInterface.h:27
void handleInitializeAPLRenderers(rapidjson::Document &payload) override
tuple message
Definition: gtest_output_test.py:331
Definition: CustomerDataHandler.h:34
void notifyAuthorizationRequest(const std::string &url, const std::string &code) override
void setObserver(const std::shared_ptr< communication::MessagingServerObserverInterface > &observer) override
void setMessageListener(std::shared_ptr< MessageListenerInterface > messageListener) override
void sendCompleteAuthorizationMessage(const std::string &url, const std::string &code, const std::string &clientId)