2 #include <swarmio/data/Message.pb.h> 3 #include <g3log/g3log.hpp> 14 message.mutable_echo()->mutable_payload()->resize(size,
'P');
17 LOG(DBUG) <<
"A ping request will be sent to node [" << node->
GetUUID() <<
"]";
20 endpoint->
Tag(&message);
21 TimingAwaiter awaiter(endpoint, message.header().identifier());
22 endpoint->
Send(&message, node);
29 CHECK(sender !=
nullptr) <<
"Sender address missing";
30 CHECK(message !=
nullptr) <<
"Message is missing";
33 if (message->content_case() == data::Message::ContentCase::kEcho &&
34 message->header().reply_to() == 0)
37 LOG(DBUG) <<
"A ping request was received from node [" << sender->
GetUUID() <<
"] and will be answered";
41 reply.mutable_header()->set_reply_to(message->header().identifier());
42 reply.mutable_echo()->set_payload(message->echo().payload());
59 descriptor.set_echo_enabled(
true);
virtual void Tag(data::Message *message)=0
Set the message identifier for a message.
static TimingAwaiter Ping(Endpoint *endpoint, const Node *node, size_t size)
Measure the latency to a remote node.
virtual void Send(data::Message *message, const Node *node)=0
Send a message to a specific member of the swarm. Call with node set to nullptr to send a message to ...
An Awaiter that returns the roundtrip time of the Echo message.
virtual bool ReceiveMessage(const Node *sender, const data::Message *message) override
Delivery point of all messages.
virtual void DescribeService(data::discovery::Response &descriptor) override
Add descriptors for the service to the discovery descriptor.
Abstract base class for Endpoint implementations.
Endpoint * GetEndpoint()
Get the associated Endpoint.
virtual const std::string & GetUUID() const =0
Returns the unique identifier of the node.
Represents a Node the Endpoint knows about and can send messages to.