38 #include <msgs/Person.pb.h>
39 #include <protobuf_comm/peer.h>
41 #include <boost/asio.hpp>
42 #include <boost/lexical_cast.hpp>
44 using namespace protobuf_comm;
45 using namespace llsf_msgs;
49 static bool quit =
false;
53 signal_handler(
const boost::system::error_code &error,
int signum)
61 handle_error(
const boost::system::error_code &error)
63 printf(
"Error: %s\n", error.message().c_str());
67 handle_message(boost::asio::ip::udp::endpoint & sender,
68 uint16_t component_id,
70 std::shared_ptr<google::protobuf::Message> msg)
72 printf(
"Received message of type %u from %s\n", msg_type, sender.address().to_string().c_str());
73 std::shared_ptr<Person> p;
74 if ((p = std::dynamic_pointer_cast<Person>(msg))) {
75 printf(
"Person %i: %s <%s>\n", p->id(), p->name().c_str(), p->email().c_str());
82 main(
int argc,
char **argv)
84 unsigned short send_to_port = 1234;
85 unsigned short recv_on_port = 1234;
87 send_to_port = boost::lexical_cast<unsigned short>(argv[1]);
88 recv_on_port = boost::lexical_cast<unsigned short>(argv[2]);
92 boost::asio::io_service io_service;
98 peer->signal_error().connect(handle_error);
101 boost::asio::signal_set signals(io_service, SIGINT, SIGTERM);
104 signals.async_wait(signal_handler);
109 p.set_name(
"Tim Niemueller");
110 p.set_email(
"niemueller@kbsg.rwth-aachen.de");
122 google::protobuf::ShutdownProtobufLibrary();