16 #ifndef ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_HTTP2TRANSPORT_H_ 17 #define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_HTTP2TRANSPORT_H_ 26 #include <unordered_set> 53 :
public std::enable_shared_from_this<HTTP2Transport>
90 static std::shared_ptr<HTTP2Transport>
create(
91 std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> authDelegate,
93 std::shared_ptr<avsCommon::utils::http2::HTTP2ConnectionInterface> http2Connection,
94 std::shared_ptr<MessageConsumerInterface> messageConsumer,
95 std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
96 std::shared_ptr<TransportObserverInterface> transportObserver,
97 std::shared_ptr<PostConnectFactoryInterface> postConnectFactory,
98 std::shared_ptr<SynchronizedMessageRequestQueue> sharedRequestQueue,
100 std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>
metricRecorder =
nullptr,
101 std::shared_ptr<avsCommon::sdkInterfaces::EventTracerInterface> eventTracer =
nullptr);
108 void addObserver(std::shared_ptr<TransportObserverInterface> transportObserver);
115 void removeObserver(std::shared_ptr<TransportObserverInterface> observer);
122 std::shared_ptr<avsCommon::utils::http2::HTTP2ConnectionInterface>
getHTTP2Connection();
137 void sendMessage(std::shared_ptr<avsCommon::avs::MessageRequest> request)
override;
162 void onMessageRequestSent(
const std::shared_ptr<avsCommon::avs::MessageRequest>& request)
override;
191 WAITING_TO_RETRY_CONNECTING,
198 SERVER_SIDE_DISCONNECT,
206 friend std::ostream&
operator<<(std::ostream& stream, HTTP2Transport::State state);
224 std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> authDelegate,
226 std::shared_ptr<avsCommon::utils::http2::HTTP2ConnectionInterface> http2Connection,
227 std::shared_ptr<MessageConsumerInterface> messageConsumer,
228 std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
229 std::shared_ptr<TransportObserverInterface> transportObserver,
230 std::shared_ptr<PostConnectFactoryInterface> postConnectFactory,
231 std::shared_ptr<SynchronizedMessageRequestQueue> sharedRequestQueue,
233 std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>
metricRecorder,
234 std::shared_ptr<avsCommon::sdkInterfaces::EventTracerInterface> eventTracer);
253 State handleAuthorizing();
260 State handleConnecting();
267 State handleWaitingToRetryConnecting();
274 State handlePostConnecting();
281 State handleConnected();
288 State handleServerSideDisconnect();
295 State handleDisconnecting();
302 State handleShutdown();
312 State monitorSharedQueueWhileWaiting(
353 void notifyObserversOnConnected();
365 void notifyObserversOnServerSideDisconnect();
375 std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> m_metricRecorder;
387 std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> m_authDelegate;
393 std::shared_ptr<avsCommon::utils::http2::HTTP2ConnectionInterface> m_http2Connection;
396 std::shared_ptr<MessageConsumerInterface> m_messageConsumer;
399 std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> m_attachmentManager;
402 std::shared_ptr<PostConnectFactoryInterface> m_postConnectFactory;
405 std::shared_ptr<SynchronizedMessageRequestQueue> m_sharedRequestQueue;
408 std::shared_ptr<avsCommon::sdkInterfaces::EventTracerInterface> m_eventTracer;
411 std::mutex m_observerMutex;
414 std::unordered_set<std::shared_ptr<TransportObserverInterface>> m_observers;
417 std::thread m_thread;
420 std::shared_ptr<PostConnectInterface> m_postConnect;
426 int m_connectRetryCount;
429 int m_countOfUnfinishedMessageHandlers;
432 std::shared_ptr<PingHandler> m_pingHandler;
435 std::chrono::time_point<std::chrono::steady_clock> m_timeOfLastActivity;
438 std::atomic<bool> m_postConnected;
447 std::shared_ptr<avsCommon::utils::power::PowerResource> m_mainLoopPowerResource;
450 std::shared_ptr<avsCommon::utils::power::PowerResource> m_requestActivityPowerResource;
456 #endif // ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_HTTP2TRANSPORT_H_ void onAuthStateChange(avsCommon::sdkInterfaces::AuthObserverInterface::State newState, avsCommon::sdkInterfaces::AuthObserverInterface::Error error) override
Definition: HTTP2Transport.h:52
friend std::ostream & operator<<(std::ostream &stream, HTTP2Transport::State state)
void onForbidden(const std::string &authToken="") override
Definition: ConditionVariableWrapper.h:40
ChangedReason
Definition: ConnectionStatusObserverInterface.h:50
void onWakeConnectionRetry() override
void onMessageRequestSent(const std::shared_ptr< avsCommon::avs::MessageRequest > &request) override
Definition: MessageRequestQueueInterface.h:33
Definition: HTTP2RequestConfig.h:42
void addObserver(std::shared_ptr< TransportObserverInterface > transportObserver)
::std::string string
Definition: gtest-port.h:1097
void onDownchannelFinished() override
void onPostConnected() override
Definition: ExchangeHandlerContextInterface.h:32
void onMessageRequestFinished() override
void onDownchannelConnected() override
bool isConnected() override
State
The enum State describes the state of authorization.
Definition: AuthObserverInterface.h:34
void removeObserver(std::shared_ptr< TransportObserverInterface > observer)
Definition: PostConnectObserverInterface.h:25
void disconnect() override
void doShutdown() override
void onGoawayReceived() override
static std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder
Metric recorder shared ptr.
Definition: BaseAPLCapabilityAgentTest.cpp:261
static std::shared_ptr< HTTP2Transport > create(std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface > authDelegate, const std::string &avsGateway, std::shared_ptr< avsCommon::utils::http2::HTTP2ConnectionInterface > http2Connection, std::shared_ptr< MessageConsumerInterface > messageConsumer, std::shared_ptr< avsCommon::avs::attachment::AttachmentManagerInterface > attachmentManager, std::shared_ptr< TransportObserverInterface > transportObserver, std::shared_ptr< PostConnectFactoryInterface > postConnectFactory, std::shared_ptr< SynchronizedMessageRequestQueue > sharedRequestQueue, Configuration configuration=Configuration(), std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr, std::shared_ptr< avsCommon::sdkInterfaces::EventTracerInterface > eventTracer=nullptr)
std::chrono::steady_clock::time_point getDistantFuture()
Definition: DistantFuture.h:34
Definition: AuthObserverInterface.h:31
void onMessageRequestTimeout() override
void onActivity() override
void onPingTimeout() override
Error
The enum Error encodes possible errors which may occur when changing state.
Definition: AuthObserverInterface.h:48
void onWakeVerifyConnectivity() override
void onRequestEnqueued() override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void onMessageRequestAcknowledged(const std::shared_ptr< avsCommon::avs::MessageRequest > &request) override
void onPingRequestAcknowledged(bool success) override
void onUnRecoverablePostConnectFailure() override
std::chrono::seconds inactivityTimeout
The elapsed time without any activity before sending out a ping.
Definition: HTTP2Transport.h:71
This specifies an interface to send a message.
Definition: MessageSenderInterface.h:26
std::shared_ptr< avsCommon::utils::http2::HTTP2ConnectionInterface > getHTTP2Connection()
Definition: MessageRequestQueue.h:37
void sendMessage(std::shared_ptr< avsCommon::avs::MessageRequest > request) override
Definition: HTTP2Transport.h:64
Definition: HTTP2ConnectionObserverInterface.h:27
std::string getAVSGateway() override
Definition: TransportInterface.h:31
std::shared_ptr< avsCommon::utils::http2::HTTP2RequestInterface > createAndSendRequest(const avsCommon::utils::http2::HTTP2RequestConfig &cfg) override