25 #include <boost/shared_array.hpp>
29 namespace RobotRaconteur
47 class TcpTransportConnection;
51 class TcpWebSocketConnector;
52 class TcpWSSWebSocketConnector;
53 class TcpSocketAcceptor;
133 friend class TcpTransportConnection;
134 friend class detail::TcpConnector;
135 friend class detail::TcpWebSocketConnector;
136 friend class detail::TcpWSSWebSocketConnector;
142 RR_UNORDERED_MAP<uint32_t, RR_SHARED_PTR<ITransportConnection> > TransportConnections;
143 boost::mutex TransportConnections_lock;
145 std::list<RR_WEAK_PTR<ITransportConnection> > closing_TransportConnections;
146 std::list<RR_WEAK_PTR<ITransportConnection> > incoming_TransportConnections;
165 RR_OVIRTUAL
bool IsServer() const RR_OVERRIDE;
166 RR_OVIRTUAL
bool IsClient() const RR_OVERRIDE;
178 virtual int32_t GetDefaultReceiveTimeout();
190 virtual
void SetDefaultReceiveTimeout(int32_t milliseconds);
200 virtual int32_t GetDefaultConnectTimeout();
212 virtual
void SetDefaultConnectTimeout(int32_t milliseconds);
214 RR_OVIRTUAL std::
string GetUrlSchemeString() const RR_OVERRIDE;
216 virtual int32_t GetListenPort();
218 RR_OVIRTUAL
void SendMessage(const RR_INTRUSIVE_PTR<Message>& m) RR_OVERRIDE;
220 RR_OVIRTUAL
void AsyncSendMessage(
221 const RR_INTRUSIVE_PTR<Message>& m,
224 RR_OVIRTUAL
void AsyncCreateTransportConnection(
225 boost::string_ref url, const RR_SHARED_PTR<Endpoint>& e,
226 boost::function<
void(const RR_SHARED_PTR<ITransportConnection>&,
229 RR_OVIRTUAL RR_SHARED_PTR<ITransportConnection> CreateTransportConnection(
230 boost::string_ref url, const RR_SHARED_PTR<Endpoint>& e) RR_OVERRIDE;
232 RR_OVIRTUAL
void CloseTransportConnection(const RR_SHARED_PTR<Endpoint>& e) RR_OVERRIDE;
235 virtual
void CloseTransportConnection_timed(const boost::system::error_code& err, const RR_SHARED_PTR<Endpoint>& e,
236 const RR_SHARED_PTR<
void>& timer);
249 virtual
void StartServer(int32_t porte,
bool localhost_only = false,
250 boost::function<
bool(const boost::asio::ip::tcp::endpoint&)> accept_filter = 0);
260 virtual
void StartServerUsingPortSharer();
268 virtual
bool IsPortSharerRunning();
278 virtual
void StartServer(const std::vector<boost::asio::ip::tcp::endpoint>& listen_endpoints,
279 boost::function<
bool(const boost::asio::ip::tcp::endpoint&)> accept_filter = 0);
286 virtual std::vector<boost::asio::ip::tcp::endpoint> GetListenEndpoints();
293 virtual std::vector<boost::asio::ip::tcp::endpoint> GetResolvedListenEndpoints();
300 RR_OVIRTUAL std::vector<std::
string> GetServerListenUrls() RR_OVERRIDE;
302 RR_OVIRTUAL
bool CanConnectService(boost::string_ref url) RR_OVERRIDE;
304 RR_OVIRTUAL
void Close() RR_OVERRIDE;
306 RR_OVIRTUAL
void CheckConnection(uint32_t endpoint) RR_OVERRIDE;
315 void EnableNodeDiscoveryListening(uint32_t flags = (IPNodeDiscoveryFlags_LINK_LOCAL));
321 void DisableNodeDiscoveryListening();
330 void EnableNodeAnnounce(uint32_t flags = (IPNodeDiscoveryFlags_LINK_LOCAL));
336 void DisableNodeAnnounce();
345 int32_t GetNodeAnnouncePeriod();
354 void SetNodeAnnouncePeriod(int32_t millis);
356 void SendDiscoveryRequest();
358 RR_OVIRTUAL
void PeriodicCleanupTask() RR_OVERRIDE;
360 RR_OVIRTUAL uint32_t TransportCapability(boost::string_ref name) RR_OVERRIDE;
362 static
void GetLocalAdapterIPAddresses(std::vector<boost::asio::ip::address>& addresses);
364 RR_OVIRTUAL
void MessageReceived(const RR_INTRUSIVE_PTR<Message>& m) RR_OVERRIDE;
376 virtual int32_t GetDefaultHeartbeatPeriod();
387 virtual
void SetDefaultHeartbeatPeriod(int32_t milliseconds);
396 virtual int32_t GetMaxMessageSize();
405 virtual
void SetMaxMessageSize(int32_t size);
414 virtual int32_t GetMaxConnectionCount();
422 virtual
void SetMaxConnectionCount(int32_t count);
430 virtual
bool GetRequireTls();
437 virtual
void SetRequireTls(
bool require_tls);
446 virtual
void LoadTlsNodeCertificate();
454 virtual
bool IsTlsNodeCertificateLoaded();
466 virtual
bool IsTransportConnectionSecure(uint32_t endpoint);
469 virtual
bool IsTransportConnectionSecure(const RR_SHARED_PTR<Endpoint>& endpoint);
472 virtual
bool IsTransportConnectionSecure(const RR_SHARED_PTR<
RRObject>& obj);
475 virtual
bool IsTransportConnectionSecure(const RR_SHARED_PTR<ITransportConnection>& transport);
491 virtual
bool IsSecurePeerIdentityVerified(uint32_t endpoint);
494 virtual
bool IsSecurePeerIdentityVerified(const RR_SHARED_PTR<Endpoint>& endpoint);
496 virtual
bool IsSecurePeerIdentityVerified(const RR_SHARED_PTR<
RRObject>& obj);
498 virtual
bool IsSecurePeerIdentityVerified(const RR_SHARED_PTR<ITransportConnection>& transport);
509 virtual std::
string GetSecurePeerIdentity(uint32_t endpoint);
512 virtual std::
string GetSecurePeerIdentity(const RR_SHARED_PTR<Endpoint>& endpoint);
514 virtual std::
string GetSecurePeerIdentity(const RR_SHARED_PTR<
RRObject>& obj);
516 virtual std::
string GetSecurePeerIdentity(const RR_SHARED_PTR<ITransportConnection>& transport);
526 virtual
bool GetAcceptWebSockets();
535 virtual
void SetAcceptWebSockets(
bool value);
544 virtual std::vector<std::
string> GetWebSocketAllowedOrigins();
583 virtual
void AddWebSocketAllowedOrigin(boost::string_ref origin);
592 virtual
void RemoveWebSocketAllowedOrigin(boost::string_ref origin);
604 virtual
bool GetDisableMessage4();
615 virtual
void SetDisableMessage4(
bool d);
628 virtual
bool GetDisableStringTable();
640 virtual
void SetDisableStringTable(
bool d);
653 virtual
bool GetDisableAsyncMessageIO();
665 virtual
void SetDisableAsyncMessageIO(
bool d);
667 template <typename T, typename F>
668 boost::signals2::connection AddCloseListener(const RR_SHARED_PTR<T>& t, const F& f)
670 boost::mutex::scoped_lock lock(closed_lock);
675 return boost::signals2::connection();
678 return close_signal.connect(boost::signals2::signal<
void()>::slot_type(boost::bind(f, t.get())).track(t));
682 RR_OVIRTUAL
void LocalNodeServicesChanged() RR_OVERRIDE;
684 boost::mutex node_discovery_lock;
685 RR_SHARED_PTR<
void> node_discovery;
687 std::vector<RR_SHARED_PTR<detail::TcpSocketAcceptor> > acceptors;
688 boost::mutex acceptor_lock;
690 static
void handle_accept(const RR_SHARED_PTR<
TcpTransport>& parent,
691 const RR_SHARED_PTR<detail::TcpSocketAcceptor>& acceptor,
692 const RR_SHARED_PTR<boost::asio::ip::tcp::socket>& socket,
693 const boost::system::error_code& error);
695 virtual
void register_transport(const RR_SHARED_PTR<ITransportConnection>& connection);
696 virtual
void erase_transport(const RR_SHARED_PTR<ITransportConnection>& connection);
697 virtual
void incoming_transport(const RR_SHARED_PTR<ITransportConnection>& connection);
699 boost::mutex parameter_lock;
700 int32_t heartbeat_period;
701 int32_t default_connect_timeout;
702 int32_t default_receive_timeout;
703 int32_t max_message_size;
704 int32_t max_connection_count;
705 bool disable_message4;
706 bool disable_string_table;
707 bool disable_async_message_io;
709 boost::shared_ptr<
void> GetTlsContext();
711 boost::shared_ptr<
void> tls_context;
712 boost::mutex tls_context_lock;
715 RR_SHARED_PTR<
void> port_sharer_client;
716 boost::mutex port_sharer_client_lock;
718 bool accept_websockets;
720 std::vector<std::
string> allowed_websocket_origins;
723 boost::signals2::signal<
void()> close_signal;
724 boost::mutex closed_lock;
727 #ifndef ROBOTRACONTEUR_NO_CXX11_TEMPLATE_ALIASES
IPNodeDiscoveryFlags
Configuration flags for IP network node discovery.
Definition: TcpTransport.h:36
@ IPNodeDiscoveryFlags_IPV4_BROADCAST
Use IPv4 255.255.255.255 broadcast addresses.
Definition: TcpTransport.h:44
@ IPNodeDiscoveryFlags_LINK_LOCAL
Use IPv6 FF02:: link local multicast addresses.
Definition: TcpTransport.h:40
@ IPNodeDiscoveryFlags_NODE_LOCAL
Use IPv6 FF01:: node local multicast addresses.
Definition: TcpTransport.h:38
@ IPNodeDiscoveryFlags_SITE_LOCAL
Use IPv6 FF05:: site local multicast addresses.
Definition: TcpTransport.h:42
boost::shared_ptr< TcpTransport > TcpTransportPtr
Convenience alias for TcpTransport shared_ptr.
Definition: TcpTransport.h:729
Base class for all Robot Raconteur objects.
Definition: DataTypes.h:227
Base class for Robot Raconteur exceptions.
Definition: Error.h:50
static boost::shared_ptr< RobotRaconteurNode > sp()
Singleton shared_ptr accessor.
Transport for Transport Control Protocol Internet Protocol (TCP/IP) networks.
Definition: TcpTransport.h:132
TcpTransport(const boost::shared_ptr< RobotRaconteurNode > &node=RobotRaconteurNode::sp())
Construct a new TcpTransport.
Base class for transports.
Definition: Transport.h:120