31 #include <boost/date_time.hpp>
32 #include <boost/atomic.hpp>
39 namespace RobotRaconteur
42 class ROBOTRACONTEUR_CORE_API RobotRaconteurNode;
43 class ROBOTRACONTEUR_CORE_API ITransportConnection;
45 class ROBOTRACONTEUR_CORE_API Endpoint :
private boost::noncopyable
48 boost::atomic<uint32_t> m_LocalEndpoint;
49 boost::atomic<uint32_t> m_RemoteEndpoint;
50 boost::shared_mutex m_RemoteNodeName_lock;
51 std::string m_RemoteNodeName;
52 boost::shared_mutex m_RemoteNodeID_lock;
53 NodeID m_RemoteNodeID;
54 boost::atomic<uint32_t> m_transport;
56 boost::mutex m_TransportConnection_lock;
57 RR_WEAK_PTR<ITransportConnection> m_TransportConnection;
59 boost::atomic<boost::posix_time::ptime> m_LastMessageReceivedTime;
60 boost::atomic<boost::posix_time::ptime> m_LastMessageSentTime;
62 boost::atomic<uint16_t> MessageNumber;
65 uint32_t GetLocalEndpoint();
66 void SetLocalEndpoint(uint32_t endpoint);
68 uint32_t GetRemoteEndpoint();
69 void SetRemoteEndpoint(uint32_t endpoint);
71 std::string GetRemoteNodeName();
72 void SetRemoteNodeName(boost::string_ref name);
74 NodeID GetRemoteNodeID();
75 void SetRemoteNodeID(
const NodeID&
id);
77 uint32_t GetTransport();
78 void SetTransport(uint32_t transport);
80 virtual RR_SHARED_PTR<ITransportConnection> GetTransportConnection();
81 virtual void SetTransportConnection(
const RR_SHARED_PTR<ITransportConnection>& c);
83 boost::posix_time::ptime GetLastMessageReceivedTime();
84 void SetLastMessageReceivedTime(boost::posix_time::ptime time);
86 boost::posix_time::ptime GetLastMessageSentTime();
87 void SetLastMessageSentTime(boost::posix_time::ptime time);
89 virtual void SendMessage(
const RR_INTRUSIVE_PTR<Message>& m);
91 virtual void AsyncSendMessage(
const RR_INTRUSIVE_PTR<Message>& m,
92 const boost::function<
void(
const RR_SHARED_PTR<RobotRaconteurException>&)>& callback);
94 virtual void MessageReceived(
const RR_INTRUSIVE_PTR<Message>& m) = 0;
96 virtual void PeriodicCleanupTask();
98 virtual void TransportConnectionClosed(uint32_t endpoint);
101 virtual void CheckEndpointCapabilityMessage(
const RR_INTRUSIVE_PTR<Message>& m);
104 virtual uint32_t EndpointCapability(boost::string_ref name);
106 Endpoint(
const RR_SHARED_PTR<RobotRaconteurNode>& node);
108 virtual ~Endpoint() {}
110 RR_SHARED_PTR<RobotRaconteurNode> GetNode();
113 RR_WEAK_PTR<RobotRaconteurNode> node;
116 #ifndef ROBOTRACONTEUR_NO_CXX11_TEMPLATE_ALIASES
117 using EndpointPtr = RR_SHARED_PTR<Endpoint>;
118 using EndpointConstPtr = RR_SHARED_PTR<const Endpoint>;