Skip to content

Commit

Permalink
Simplify example
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey committed Jan 11, 2024
1 parent 49e20c1 commit bc1e4a1
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions example/requester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,16 @@ bool srvEcho(const gz::msgs::StringMsg &_req,
return true;
}

class Responder {
public:
Responder() {
// Request the "/echo" service.
std::string service = "/echo";

// Advertise a service.
if (!this->node.Advertise(service, srvEcho)) {
std::cerr << "Error advertising service [" << service << "]" << std::endl;
}
}

private:
gz::transport::Node node;
};

void runResponder()
{
using namespace std::literals;
std::this_thread::sleep_for(2s);
gz::transport::Node node;
if (!node.Advertise("/echo", srvEcho))
{
std::cerr << "Error advertising service" << std::endl;
}
std::cout << "Responder started" << std::endl;
Responder responder;
std::this_thread::sleep_for(10s);
std::cout << "Responder finished" << std::endl;
}
Expand Down

0 comments on commit bc1e4a1

Please sign in to comment.