本文整理汇总了C++中zmq::message_t类的典型用法代码示例。如果您正苦于以下问题:C++ message_t类的具体用法?C++ message_t怎么用?C++ message_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了message_t类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:cpick,项目名称:mongrel2-cpp,代码行数:30,代码来源:m2pp.cpp
示例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;
}
开发者ID:carlosmccosta,项目名称:socket_to_tf,代码行数:31,代码来源:socket_to_tf.cpp
示例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)
);
}
开发者ID:danielwhitehall,项目名称:zmqmessage,代码行数:7,代码来源:ZmqTools.hpp
示例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());
}
开发者ID:zmqmessage,项目名称:zmqmessage,代码行数:10,代码来源:ZmqTools.hpp
示例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());
}
开发者ID:danielwhitehall,项目名称:zmqmessage,代码行数:7,代码来源:ZmqTools.hpp
示例6: get_string
ZMQMESSAGE_DLL_PUBLIC
inline
T
get_string(zmq::message_t& message)
{
return T(static_cast<char*>(message.data()), message.size());
}
开发者ID:zmqmessage,项目名称:zmqmessage,代码行数:7,代码来源:ZmqTools.hpp
示例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);
}
开发者ID:phamtec,项目名称:skweltch,代码行数:8,代码来源:Msg.hpp
示例8: unpack
static bool unpack(zmq::message_t& message, std::string& value) {
value.assign(
static_cast<const char*>(message.data()),
message.size()
);
return true;
}
开发者ID:griffordson,项目名称:cocaine-core,代码行数:8,代码来源:io.hpp
示例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;
}
开发者ID:zmqmessage,项目名称:zmqmessage,代码行数:12,代码来源:ZmqTools.hpp
示例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());
}
开发者ID:zmqmessage,项目名称:zmqmessage,代码行数:8,代码来源:ZmqTools.hpp
示例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 {
开发者ID:carlosmccosta,项目名称:socket_to_tf,代码行数:9,代码来源:socket_to_tf.cpp
示例12: unpack
static inline
void
unpack(/* const */ zmq::message_t& message,
std::string& value)
{
value.assign(
static_cast<const char*>(message.data()),
message.size()
);
}
开发者ID:zloidemon,项目名称:cocaine-core,代码行数:10,代码来源:io.hpp
示例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;
}
开发者ID:pombredanne,项目名称:cocaine-dealer,代码行数:12,代码来源:networking.hpp
示例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()
);
}
开发者ID:zloidemon,项目名称:cocaine-core,代码行数:13,代码来源:io.hpp
示例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;
}
开发者ID:bogdad,项目名称:cocaine-dealer,代码行数:14,代码来源:networking.cpp
示例16: m_valid
Request::Request(const zmq::message_t& message) : m_valid(false)
{
std::string in(static_cast<const char*>(message.data()), message.size());
std::istringstream stream(in);
std::string path;
std::string headers;
// Decode message
stream >> m_sender >> m_connectionId;
stream >> path;
headers = utility::readNetString(stream);
m_body = utility::readNetString(stream);
// Decode path
if(!utility::decodeUrl(path, m_path)) {
// TODO: Throw exception
m_path = path;
}
// Parse http header
Json::Reader reader;
if ( !reader.parse(headers, m_headers) )
{
// TODO: Throw exception
}
// Parse json body
if(m_headers.isMember("METHOD") && m_headers["METHOD"] == "JSON") {
if ( !reader.parse(m_body, m_jsonBody) )
{
// TODO: Throw exception
}
}
// Parse query parameters
std::string query = m_headers.get("QUERY", std::string()).asString();
if(!query.empty()) {
std::string decodedQuery;
if(utility::decodeUrl(query, decodedQuery)) {
utility::parseQuery(decodedQuery, m_query);
}
else {
// TODO: Throw exception
}
}
m_valid = true;
}
开发者ID:samvik,项目名称:mcpp,代码行数:49,代码来源:request.cpp
示例17: get_bin
ZMQMESSAGE_DLL_PUBLIC
inline
void
get_bin(zmq::message_t& message, T& t)
{
t = *(reinterpret_cast<T*>(message.data()));
}
开发者ID:zmqmessage,项目名称:zmqmessage,代码行数:7,代码来源:ZmqTools.hpp
示例18: unpack
/** Unpacks a message from a zeromq message */
static Message unpack(const zmq::message_t &msg) {
auto begin = reinterpret_cast<const capnp::word*>(msg.data()); // NOLINT
auto end = reinterpret_cast<const capnp::word*>(static_cast<const char*>(msg.data()) + msg.size()); // NOLINT
kj::ArrayPtr<const capnp::word> ptr(begin, end);
capnp::FlatArrayMessageReader msg_reader(ptr);
capnqml::Message ret;
auto reader = msg_reader.getRoot<serialize::Message>();
ret.setType(static_cast<Message::Type>(reader.getType()));
ret.setEndpoint(reader.getEndpoint().cStr());
ret.setExpectsAnswer(reader.getExpectsAnswer());
ret.setId(reader.getId());
ret.setOriginator(reader.getOriginator());
ret.setSchema(reader.getSchema().cStr());
auto payload = reader.getPayload();
Message::Payload data(payload.begin(), payload.end());
ret.setData(std::move(data));
return ret;
}
开发者ID:raffber,项目名称:capnqml,代码行数:19,代码来源:zmq_channel.hpp
示例19: it
void
blastbeat_t::on_body(const std::string& sid,
zmq::message_t& body)
{
stream_map_t::iterator it(
m_streams.find(sid)
);
if(it == m_streams.end()) {
COCAINE_LOG_WARNING(m_log, "received an unknown session body");
return;
}
try {
it->second->write(
static_cast<const char*>(body.data()),
body.size()
);
} catch(const cocaine::error_t& e) {
COCAINE_LOG_ERROR(m_log, "unable to push a body chunk to a session - %s", e.what());
}
}
开发者ID:euroelessar,项目名称:cocaine-plugins,代码行数:22,代码来源:driver.cpp
示例20: copy_msg
/**
* Copy contents of one message part to another
*/
inline void
copy_msg(zmq::message_t& target, zmq::message_t& source)
throw(ZmqErrorType)
{
try
{
target.copy(&source);
}
catch (const zmq::error_t& e)
{
throw_zmq_exception(e);
}
}
开发者ID:danielwhitehall,项目名称:zmqmessage,代码行数:16,代码来源:ZmqTools.hpp
注:本文中的zmq::message_t类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论