本文整理汇总了C++中zmq::message_t类的典型用法代码示例。如果您正苦于以下问题:C++ message_t类的具体用法?C++ message_t怎么用?C++ message_t使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了message_t类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
request request::parse(zmq::message_t& msg) {
request req;
std::string result(static_cast<const char *>(msg.data()), msg.size());
std::vector<std::string> results = utils::split(result, " ", 3);
req.sender = results[0];
req.conn_id = results[1];
req.path = results[2];
std::string body;
std::string ign;
req.headers = utils::parse_json(utils::parse_netstring(results[3], body));
req.body = utils::parse_netstring(body, ign);
//check disconnect flag
req.disconnect = false;
for (std::vector<header>::const_iterator it = req.headers.begin();
it != req.headers.end(); ++it) {
if (it->first == "METHOD" && it->second == "JSON" &&
req.body == "{\"type\":\"disconnect\"}") {
req.disconnect = true;
break;
}
}
return req;
}
示例2: updateTransformFromSocketTransform
bool SocketToTF::updateTransformFromSocketTransform(zmq::message_t& message) {
socket_to_tf::TransformStamped transform;
boost::iostreams::basic_array_source<char> source((char*)message.data(), message.size());
boost::iostreams::stream<boost::iostreams::basic_array_source <char> > input_stream(source);
boost::archive::binary_iarchive ia(input_stream);
ia >> transform;
if (boost::math::isfinite(transform.x) && boost::math::isfinite(transform.y) && boost::math::isfinite(transform.z) &&
boost::math::isfinite(transform.qx) && boost::math::isfinite(transform.qy) && boost::math::isfinite(transform.qz) && boost::math::isfinite(transform.qw)) {
transform_stamped_.transform.translation.x = transform.x;
transform_stamped_.transform.translation.y = transform.y;
transform_stamped_.transform.translation.z = transform.z;
transform_stamped_.transform.rotation.x = transform.qx;
transform_stamped_.transform.rotation.y = transform.qy;
transform_stamped_.transform.rotation.z = transform.qz;
transform_stamped_.transform.rotation.w = transform.qw;
transform_stamped_.child_frame_id = transform.source_frame;
transform_stamped_.header.frame_id = transform.target_frame;
transform_stamped_.header.stamp.sec = transform.timestamp_seconds;
transform_stamped_.header.stamp.nsec = transform.timestamp_nanoseconds;
std::stringstream ss_data;
ss_data << "{ " << transform.x << " " << transform.y << " " << transform.z << " " << transform.qx << " " << transform.qy << " " << transform.qz << " " << transform.qw << " " << transform.source_frame << " " << transform.target_frame << " }";
std::string transform_data = ss_data.str();
ROS_INFO_STREAM("Received message with size " << message.size() << ": " << transform_data);
return true;
}
return false;
}
示例3: get_string
inline T
get_string(zmq::message_t& message, size_t limit)
{
return T(
static_cast<char*>(message.data()), std::min(message.size(), limit)
);
}
示例4: get_raw
/**
* Return memory region as RawMessage. No copying takes place.
*/
ZMQMESSAGE_DLL_PUBLIC
inline
RawMessage
get_raw(zmq::message_t& message)
{
return RawMessage(message.data(), message.size());
}
示例5: get
inline
T
get(zmq::message_t& message,
typename Private::EnableIf<Private::IsStr<T>::value>::type* = 0)
{
return T(static_cast<char*>(message.data()), message.size());
}
示例6: get_string
ZMQMESSAGE_DLL_PUBLIC
inline
T
get_string(zmq::message_t& message)
{
return T(static_cast<char*>(message.data()), message.size());
}
示例7: Msg
Msg(const zmq::message_t &message) {
msgpack::unpacked msg;
msgpack::unpack(&msg, (const char *)message.data(), message.size());
msgpack::object obj = msg.get();
obj.convert(&data);
}
示例8: unpack
static bool unpack(zmq::message_t& message, std::string& value) {
value.assign(
static_cast<const char*>(message.data()),
message.size()
);
return true;
}
示例9: msgcmp
/**
* Compare message contents to specified memory region.
* @return like @c memcmp
*/
ZMQMESSAGE_DLL_PUBLIC
inline
int
msgcmp(zmq::message_t& message, const char* str, size_t len)
{
int ret = memcmp(message.data(), str, std::min(message.size(), len));
return ret ? ret : message.size() - len;
}
示例10: get
ZMQMESSAGE_DLL_PUBLIC
inline
void
get(zmq::message_t& message, T& t,
typename Private::EnableIf<Private::IsStr<T>::value>::type* = 0)
{
t = T(static_cast<char*>(message.data()), message.size());
}
示例11: updateTransformFromSocketPointTranslation
bool SocketToTF::updateTransformFromSocketPointTranslation(zmq::message_t& message) {
socket_to_tf::PointTranslation point_translation;
if (use_boost_to_parse_point_translation_message_) {
boost::iostreams::basic_array_source<char> source((char*)message.data(), message.size());
boost::iostreams::stream<boost::iostreams::basic_array_source <char> > input_stream(source);
boost::archive::binary_iarchive ia(input_stream);
ia >> point_translation;
} else {
示例12: unpack
static inline
void
unpack(/* const */ zmq::message_t& message,
std::string& value)
{
value.assign(
static_cast<const char*>(message.data()),
message.size()
);
}
示例13: recv_zmq_message
static bool recv_zmq_message(zmq::socket_t& sock,
zmq::message_t& msg,
T& object,
int flags = ZMQ_NOBLOCK)
{
if (!sock.recv(&msg, flags)) {
return false;
}
memcpy(&object, msg.data(), msg.size());
return true;
}
示例14: pack
static inline
void
pack(zmq::message_t& message,
const std::string& value)
{
message.rebuild(value.size());
std::memcpy(
message.data(),
value.data(),
value.size()
);
}
示例15:
bool
nutils::recv_zmq_message(zmq::socket_t& sock,
zmq::message_t& msg,
std::string& str,
int flags)
{
if (!sock.recv(&msg, flags)) {
return false;
}
str.clear();
str.append(reinterpret_cast<char*>(msg.data()), msg.size());
return true;
}