25 #include <boost/shared_array.hpp>
29 namespace RobotRaconteur
31 class ROBOTRACONTEUR_CORE_API LocalTransportConnection;
35 class LocalTransportFDs;
36 class LocalTransportDiscovery;
37 class LocalTransport_socket;
38 class LocalTransport_acceptor;
92 friend class LocalTransportConnection;
95 std::string socket_file_name;
100 RR_UNORDERED_MAP<uint32_t, RR_SHARED_PTR<ITransportConnection> > TransportConnections;
101 boost::mutex TransportConnections_lock;
120 RR_OVIRTUAL
bool IsServer() const RR_OVERRIDE;
122 RR_OVIRTUAL
bool IsClient() const RR_OVERRIDE;
124 RR_OVIRTUAL std::
string GetUrlSchemeString() const RR_OVERRIDE;
126 RR_OVIRTUAL std::vector<std::
string> GetServerListenUrls() RR_OVERRIDE;
128 RR_OVIRTUAL
void SendMessage(const RR_INTRUSIVE_PTR<Message>& m) RR_OVERRIDE;
130 RR_OVIRTUAL
void AsyncSendMessage(
131 const RR_INTRUSIVE_PTR<Message>& m,
134 RR_OVIRTUAL
void AsyncCreateTransportConnection(
135 boost::string_ref url, const RR_SHARED_PTR<Endpoint>& e,
136 boost::function<
void(const RR_SHARED_PTR<ITransportConnection>&,
139 RR_OVIRTUAL RR_SHARED_PTR<ITransportConnection> CreateTransportConnection(
140 boost::string_ref url, const RR_SHARED_PTR<Endpoint>& e) RR_OVERRIDE;
142 RR_OVIRTUAL
void CloseTransportConnection(const RR_SHARED_PTR<Endpoint>& e) RR_OVERRIDE;
145 virtual
void AsyncCreateTransportConnection2(
146 const RR_SHARED_PTR<detail::LocalTransport_socket>& socket, const std::
string& noden,
148 boost::function<
void(const RR_SHARED_PTR<ITransportConnection>&,
151 virtual
void CloseTransportConnection_timed(const boost::system::error_code& err, const RR_SHARED_PTR<Endpoint>& e,
152 const RR_SHARED_PTR<
void>& timer);
170 static
bool IsLocalTransportSupported();
182 virtual
void StartClientAsNodeName(boost::string_ref name);
202 virtual
void StartServerAsNodeName(boost::string_ref name,
bool public_ = false);
217 virtual
void StartServerAsNodeID(const
NodeID& nodeid,
bool public_ = false);
219 RR_OVIRTUAL
bool CanConnectService(boost::string_ref url) RR_OVERRIDE;
221 RR_OVIRTUAL
void Close() RR_OVERRIDE;
223 RR_OVIRTUAL
void CheckConnection(uint32_t endpoint) RR_OVERRIDE;
225 RR_OVIRTUAL
void PeriodicCleanupTask() RR_OVERRIDE;
227 RR_OVIRTUAL uint32_t TransportCapability(boost::string_ref name) RR_OVERRIDE;
229 RR_OVIRTUAL
void MessageReceived(const RR_INTRUSIVE_PTR<Message>& m) RR_OVERRIDE;
231 RR_OVIRTUAL
void AsyncGetDetectedNodes(
232 const std::vector<std::
string>& schemes,
233 const boost::function<
void(const RR_SHARED_PTR<std::vector<
NodeDiscoveryInfo> >&)>& handler,
237 virtual int32_t GetMaxMessageSize();
239 virtual
void SetMaxMessageSize(int32_t size);
242 virtual
bool GetDisableMessage4();
244 virtual
void SetDisableMessage4(
bool d);
247 virtual
bool GetDisableStringTable();
249 virtual
void SetDisableStringTable(
bool d);
252 virtual
bool GetDisableAsyncMessageIO();
254 virtual
void SetDisableAsyncMessageIO(
bool d);
262 virtual
void EnableNodeDiscoveryListening();
268 virtual
void DisableNodeDiscoveryListening();
270 template <typename T, typename F>
271 boost::signals2::connection AddCloseListener(const RR_SHARED_PTR<T>& t, const F& f)
273 boost::mutex::scoped_lock lock(closed_lock);
278 return boost::signals2::connection();
281 return close_signal.connect(boost::signals2::signal<
void()>::slot_type(boost::bind(f, t.get())).track(t));
285 RR_OVIRTUAL
void LocalNodeServicesChanged() RR_OVERRIDE;
287 RR_SHARED_PTR<detail::LocalTransport_acceptor> acceptor;
289 boost::mutex acceptor_lock;
291 static
void handle_accept(const RR_SHARED_PTR<
LocalTransport>& parent,
292 const RR_SHARED_PTR<detail::LocalTransport_acceptor>& acceptor,
293 const RR_SHARED_PTR<detail::LocalTransport_socket>& socket,
294 const boost::system::error_code& error);
296 virtual
void register_transport(const RR_SHARED_PTR<ITransportConnection>& connection);
297 virtual
void erase_transport(const RR_SHARED_PTR<ITransportConnection>& connection);
299 boost::mutex fds_lock;
300 RR_SHARED_PTR<detail::LocalTransportFDs> fds;
302 boost::mutex parameter_lock;
303 int32_t max_message_size;
304 bool disable_message4;
305 bool disable_string_table;
306 bool disable_async_message_io;
308 RR_SHARED_PTR<detail::LocalTransportDiscovery> discovery;
309 boost::mutex discovery_lock;
312 boost::mutex closed_lock;
313 boost::signals2::signal<
void()> close_signal;
334 NodeIDAlreadyInUse() : runtime_error(
"Could not start server: NodeID already in use"){};
337 #ifndef ROBOTRACONTEUR_NO_CXX11_TEMPLATE_ALIASES
boost::shared_ptr< LocalTransport > LocalTransportPtr
Convenience alias for LocalTransport shared_ptr.
Definition: LocalTransport.h:339
#define RR_TIMEOUT_INFINITE
Disable timeout for asynchronous operations.
Definition: RobotRaconteurConstants.h:566
Transport for communication between processes using UNIX domain sockets.
Definition: LocalTransport.h:91
LocalTransport(const boost::shared_ptr< RobotRaconteurNode > &node=RobotRaconteurNode::sp())
Construct a new LocalTransport.
Raw information used to announce and detect nodes.
Definition: Discovery.h:137
Exception thrown if the NodeID is already in use.
Definition: LocalTransport.h:332
NodeID UUID storage and generation.
Definition: NodeID.h:58
Exception thrown if the NodeName is already in use.
Definition: LocalTransport.h:322
Base class for Robot Raconteur exceptions.
Definition: Error.h:50
static boost::shared_ptr< RobotRaconteurNode > sp()
Singleton shared_ptr accessor.
Base class for transports.
Definition: Transport.h:120