CppWAMP
C++11 client library for the WAMP protocol
connector.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_CONNECTOR_HPP
8 #define CPPWAMP_CONNECTOR_HPP
9 
10 //------------------------------------------------------------------------------
13 //------------------------------------------------------------------------------
14 
15 #include <functional>
16 #include <memory>
17 #include <system_error>
18 #include <vector>
19 #include "api.hpp"
20 #include "asiodefs.hpp"
21 
22 namespace wamp
23 {
24 
25 // Forward declaration
26 namespace internal {class ClientInterface;}
27 
28 //------------------------------------------------------------------------------
38 //------------------------------------------------------------------------------
39 class CPPWAMP_API Connector : public std::enable_shared_from_this<Connector>
40 {
41 public:
43  using Ptr = std::shared_ptr<Connector>;
44 
46  virtual ~Connector() {}
47 
48  virtual IoStrand strand() const = 0;
49 
50 protected:
52  using Handler =
53  std::function<void (std::error_code,
54  std::shared_ptr<internal::ClientInterface>)>;
55 
57  virtual Connector::Ptr clone() const = 0;
58 
60  virtual void establish(Handler&& handler) = 0;
61 
65  virtual void cancel() = 0;
66 
67  friend class Session;
68 };
69 
70 
71 //------------------------------------------------------------------------------
73 //------------------------------------------------------------------------------
74 using ConnectorList = std::vector<Connector::Ptr>;
75 
76 } // namespace wamp
77 
78 #endif // CPPWAMP_CONNECTOR_HPP
api.hpp
Defines macros related to exporting/importing APIs.
wamp::IoStrand
boost::asio::strand< AnyIoExecutor > IoStrand
Serializes I/O operations.
Definition: asiodefs.hpp:41
wamp::Connector::Ptr
std::shared_ptr< Connector > Ptr
Shared pointer to a Connector.
Definition: connector.hpp:43
asiodefs.hpp
Common type definitions used by transports that rely on Boost.Asio.
wamp
Definition: anyhandler.hpp:36
wamp::Connector
Abstract base class for establishing client transport endpoints.
Definition: connector.hpp:39
wamp::ConnectorList
std::vector< Connector::Ptr > ConnectorList
List of Connector objects to use when attempting connection.
Definition: connector.hpp:74
wamp::Session
Session API used by a client peer in WAMP applications.
Definition: session.hpp:110
wamp::Connector::Handler
std::function< void(std::error_code, std::shared_ptr< internal::ClientInterface >)> Handler
Asynchronous handler function type called by Connector::establish.
Definition: connector.hpp:54
wamp::Connector::~Connector
virtual ~Connector()
Destructor.
Definition: connector.hpp:46