6#include "azure/core/amqp/internal/models/amqp_protocol.hpp"
7#include "azure/core/amqp/models/amqp_value.hpp"
8#include "common/async_operation_queue.hpp"
9#include "connection_string_credential.hpp"
12#include <azure/core/credentials/credentials.hpp>
19namespace Azure {
namespace Core {
namespace Amqp {
namespace _detail {
21 class ConnectionFactory;
24#if defined(_azure_TESTING_BUILD)
26namespace Azure {
namespace Core {
namespace Amqp {
namespace Tests {
27 namespace MessageTests {
29 class MessageListenerEvents;
32 class TestConnections_ConnectionAttributes_Test;
33 class TestConnections_ConnectionOpenClose_Test;
34 class TestConnections_ConnectionListenClose_Test;
35 class TestSocketListenerEvents;
36 class LinkSocketListenerEvents;
37 class TestLinks_LinkAttachDetach_Test;
38 class TestSessions_MultipleSessionBeginEnd_Test;
39 class TestMessages_SenderOpenClose_Test;
40 class TestMessages_TestLocalhostVsTls_Test;
41 class TestMessages_SenderSendAsync_Test;
42 class TestMessages_SenderOpenClose_Test;
43 class TestMessages_ReceiverOpenClose_Test;
44 class TestMessages_ReceiverReceiveAsync_Test;
48#if defined(SAMPLES_BUILD)
49namespace LocalServerSample {
50int LocalServerSampleMain();
54namespace Azure {
namespace Core {
namespace Amqp {
namespace _internal {
60 constexpr uint16_t AmqpPort = 5672;
63 constexpr uint16_t AmqpTlsPort = 5671;
75 enum class ConnectionState
161 std::ostream& operator<<(std::ostream& stream, ConnectionState value);
168 class ConnectionEvents {
170 virtual ~ConnectionEvents() =
default;
179 virtual void OnConnectionStateChanged(
180 Connection
const& connection,
181 ConnectionState newState,
182 ConnectionState oldState)
189 virtual void OnIOError(Connection
const& connection) = 0;
192 class ConnectionEndpointEvents {
194 virtual ~ConnectionEndpointEvents() =
default;
206 virtual bool OnNewEndpoint(Connection
const& connection, Endpoint& endpoint) = 0;
210 struct ConnectionOptions final
214 std::vector<std::string> AuthenticationScopes;
220 std::chrono::milliseconds IdleTimeout{std::chrono::minutes(1)};
231 uint32_t MaxFrameSize{(std::numeric_limits<uint32_t>::max)()};
238 uint16_t MaxChannelCount{65535};
246 Models::AmqpMap Properties;
253 uint16_t Port{AmqpTlsPort};
269 std::string ContainerId;
273 bool EnableTrace{
false};
276 class Connection final {
287 std::string
const& hostName,
288 std::shared_ptr<Credentials::TokenCredential> credential,
289 ConnectionOptions
const& options,
290 ConnectionEvents* eventHandler =
nullptr);
302 Network::_internal::Transport
const& transport,
303 ConnectionOptions
const& options,
304 ConnectionEvents* eventHandler,
305 ConnectionEndpointEvents* endpointEvents);
319 Session CreateSession(SessionOptions
const& options = {}, SessionEvents* eventHandler =
nullptr)
332 Session CreateSession(
333 Endpoint& newEndpoint,
334 SessionOptions
const& options = {},
335 SessionEvents* eventHandler =
nullptr)
const;
380 std::string
const& condition = {},
381 std::string
const& description = {},
382 Models::AmqpValue info = {});
388 std::string GetHost()
const;
394 uint16_t GetPort()
const;
400 uint32_t GetMaxFrameSize()
const;
406 uint32_t GetRemoteMaxFrameSize()
const;
412 uint16_t GetMaxChannel()
const;
418 std::chrono::milliseconds GetIdleTimeout()
const;
424 Models::AmqpMap GetProperties()
const;
442 void SetIdleEmptyFrameSendPercentage(
double idleTimeoutEmptyFrameSendRatio);
451 Connection(std::shared_ptr<_detail::ConnectionImpl> impl) : m_impl{impl} {}
453 std::shared_ptr<_detail::ConnectionImpl> m_impl;
454 friend class _detail::ConnectionFactory;
455#if _azure_TESTING_BUILD
456 friend class Azure::Core::Amqp::Tests::MessageTests::AmqpServerMock;
457 friend class Azure::Core::Amqp::Tests::MessageTests::MessageListenerEvents;
458 friend class Azure::Core::Amqp::Tests::TestSocketListenerEvents;
459 friend class Azure::Core::Amqp::Tests::LinkSocketListenerEvents;
460 friend class Azure::Core::Amqp::Tests::TestConnections_ConnectionAttributes_Test;
461 friend class Azure::Core::Amqp::Tests::TestConnections_ConnectionOpenClose_Test;
462 friend class Azure::Core::Amqp::Tests::TestConnections_ConnectionListenClose_Test;
463 friend class Azure::Core::Amqp::Tests::TestSessions_MultipleSessionBeginEnd_Test;
464 friend class Azure::Core::Amqp::Tests::TestLinks_LinkAttachDetach_Test;
465 friend class Azure::Core::Amqp::Tests::TestMessages_SenderOpenClose_Test;
466 friend class Azure::Core::Amqp::Tests::TestMessages_TestLocalhostVsTls_Test;
467 friend class Azure::Core::Amqp::Tests::TestMessages_SenderSendAsync_Test;
468 friend class Azure::Core::Amqp::Tests::TestMessages_SenderOpenClose_Test;
472 friend int LocalServerSample::LocalServerSampleMain();