CppWAMP
C++11 client library for the WAMP protocol
tcp.hpp
Go to the documentation of this file.
1 /*------------------------------------------------------------------------------
2  Copyright Butterfly Energy Systems 2014-2015, 2022.
3  Distributed under the Boost Software License, Version 1.0.
4  http://www.boost.org/LICENSE_1_0.txt
5 ------------------------------------------------------------------------------*/
6 
7 #ifndef CPPWAMP_TCP_HPP
8 #define CPPWAMP_TCP_HPP
9 
10 //------------------------------------------------------------------------------
13 //------------------------------------------------------------------------------
14 
15 #include <cassert>
16 #include <memory>
17 #include <string>
18 #include <utility>
19 #include "api.hpp"
20 #include "asiodefs.hpp"
21 #include "connector.hpp"
22 #include "tcphost.hpp"
23 #include "traits.hpp"
24 
25 #ifndef CPPWAMP_COMPILED_LIB
26  #include "internal/asioconnector.hpp"
27  #include "internal/rawsockconnector.hpp"
28  #include "internal/tcpopener.hpp"
29 #endif
30 
31 namespace wamp
32 {
33 
34 //------------------------------------------------------------------------------
44 //------------------------------------------------------------------------------
45 template <typename TCodec>
46 CPPWAMP_API Connector::Ptr connector(
47  AnyIoExecutor exec,
48  TcpHost host
49 );
50 
51 #ifndef CPPWAMP_COMPILED_LIB
52 template <typename TCodec>
53 Connector::Ptr connector(AnyIoExecutor exec, TcpHost host)
54 {
55  using Endpoint = internal::AsioConnector<internal::TcpOpener>;
56  using ConcreteConnector = internal::RawsockConnector<TCodec, Endpoint>;
57  return ConcreteConnector::create(exec, std::move(host));
58 }
59 #endif
60 
61 
62 //------------------------------------------------------------------------------
73 //------------------------------------------------------------------------------
74 template <typename TCodec, typename TExecutionContext>
75 CPPWAMP_ENABLED_TYPE(Connector::Ptr, isExecutionContext<TExecutionContext>())
76 connector(
77  TExecutionContext& context,
79  TcpHost host
80 )
81 {
82  return connector<TCodec>(context.get_executor(), std::move(host));
83 }
84 
85 } // namespace wamp
86 
87 #endif // CPPWAMP_TCP_HPP
wamp::AnyIoExecutor
boost::asio::any_io_executor AnyIoExecutor
Polymorphic executor for all I/O objects.
Definition: asiodefs.hpp:27
connector.hpp
Contains the declaration of the Connector abstract base class.
api.hpp
Defines macros related to exporting/importing APIs.
wamp::Connector::Ptr
std::shared_ptr< Connector > Ptr
Shared pointer to a Connector.
Definition: connector.hpp:43
wamp::TcpHost
Contains TCP host address information, as well as other socket options.
Definition: tcphost.hpp:103
asiodefs.hpp
Common type definitions used by transports that rely on Boost.Asio.
wamp
Definition: anyhandler.hpp:36
tcphost.hpp
Contains facilities for specifying TCP transport parameters and options.
traits.hpp
Contains general-purpose type traits.