I am a newbie in ZeroMQ.
I use ROS frequently. Hence I am confused by the subscriber in ZeroMQ. Most of the time in ROS, the subscriber is having a callback function, which is called automatically whenever data is available in the corresponding rostopic.
Please see below code snippet, borrowed from ROS wiki:
void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
ROS_INFO("I heard: [%s]", msg->data.c_str());
}
//define subscriber and callback function associated with it
ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
However, in ZeroMQ, it seems that subscriber is kept in a loop to receive the data, as shown below:
for (int update_nbr = 0; update_nbr < 100; update_nbr++)
{
zmq::message_t update;
int zipcode, temperature, relhumidity;
// receive the data
subscriber.recv(&update);
// do something with data
std::istringstream iss(static_cast<char*>(update.data()));
iss >> zipcode >> temperature >> relhumidity;
}
The above code is borrowed from ZeroMQ wiki.
Does there exist any callback-mechanism, similar to ROS Subscriber, in ZeroMQ too?