wamp_transport.hpp
1 //
3 // Copyright (c) Crossbar.io Technologies GmbH and contributors
4 //
5 // Boost Software License - Version 1.0 - August 17th, 2003
6 //
7 // Permission is hereby granted, free of charge, to any person or organization
8 // obtaining a copy of the software and accompanying documentation covered by
9 // this license (the "Software") to use, reproduce, display, distribute,
10 // execute, and transmit the Software, and to prepare derivative works of the
11 // Software, and to permit third-parties to whom the Software is furnished to
12 // do so, all subject to the following:
13 //
14 // The copyright notices in the Software and this entire statement, including
15 // the above license grant, this restriction and the following disclaimer,
16 // must be included in all copies of the Software, in whole or in part, and
17 // all derivative works of the Software, unless such copies or derivative
18 // works are solely in the form of machine-executable object code generated by
19 // a source language processor.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 // DEALINGS IN THE SOFTWARE.
28 //
30 
31 #ifndef AUTOBAHN_WAMP_TRANSPORT_HPP
32 #define AUTOBAHN_WAMP_TRANSPORT_HPP
33 
34 #include "boost_config.hpp"
35 
36 #include <memory>
37 #include <string>
38 
39 namespace autobahn {
40 
41 class wamp_message;
42 class wamp_transport_handler;
43 
50 {
51 public:
55  using pause_handler = std::function<void()>;
56 
60  using resume_handler = std::function<void()>;
61 
62 public:
66  virtual ~wamp_transport() = default;
67 
68  /*
69  * CONNECTION INTERFACE
70  */
77  virtual boost::future<void> connect() = 0;
78 
85  virtual boost::future<void> disconnect() = 0;
86 
92  virtual bool is_connected() const = 0;
93 
94  /*
95  * SENDER INTERFACE
96  */
102  virtual void send_message(wamp_message&& message) = 0;
103 
111  virtual void set_pause_handler(pause_handler&& handler) = 0;
112 
120  virtual void set_resume_handler(resume_handler&& handler) = 0;
121 
122  /*
123  * RECEIVER INTERFACE
124  */
130  virtual void pause() = 0;
131 
136  virtual void resume() = 0;
137 
144  virtual void attach(
145  const std::shared_ptr<wamp_transport_handler>& handler) = 0;
146 
150  virtual void detach() = 0;
151 
157  virtual bool has_handler() const = 0;
158 };
159 
160 } // namespace autobahn
161 
162 #endif // AUTOBAHN_WAMP_TRANSPORT_HPP
virtual ~wamp_transport()=default
Default virtual destructor.
A class that represents a wamp message in its simplest form.
virtual void set_pause_handler(pause_handler &&handler)=0
Set the handler to be invoked when the transport detects congestion sending to the remote peer and ne...
virtual void set_resume_handler(resume_handler &&handler)=0
Set the handler to be invoked when the transport detects congestion has subsided on the remote peer a...
virtual void send_message(wamp_message &&message)=0
Send the message synchronously over the transport.
virtual void attach(const std::shared_ptr< wamp_transport_handler > &handler)=0
Attaches a handler to the transport.
virtual boost::future< void > connect()=0
Attempts to connect the transport.
Provides an abstraction for a transport to be used by the session.
virtual void pause()=0
Pause receiving of messages.
virtual void detach()=0
Detaches the handler currently attached to the transport.
virtual bool is_connected() const =0
Determines if the transport is connected.
virtual bool has_handler() const =0
Determines if the transport has a handler attached.
std::function< void()> resume_handler
Handler to invoke when resuming transport transmission.
std::function< void()> pause_handler
Handler to invoke when pausing transport transmission.
virtual boost::future< void > disconnect()=0
Attempts to disconnect the transport.
virtual void resume()=0
Resume receiving of messages.