ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
BufferConnection.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
9 
10 #include <Logging.h>
11 
12 #include <zmq.hpp>
13 
14 #include "io/rpc/Messages.h"
15 
16 using namespace cloudViewer::utility;
17 
18 namespace cloudViewer {
19 namespace io {
20 namespace rpc {
21 
22 std::shared_ptr<zmq::message_t> BufferConnection::Send(
23  zmq::message_t& send_msg) {
24  buffer_.write((char*)send_msg.data(), send_msg.size());
25 
26  auto OK = messages::Status::OK();
27  msgpack::sbuffer sbuf;
28  messages::Reply reply{OK.MsgId()};
29  msgpack::pack(sbuf, reply);
30  msgpack::pack(sbuf, OK);
31  return std::shared_ptr<zmq::message_t>(
32  new zmq::message_t(sbuf.data(), sbuf.size()));
33 }
34 
35 std::shared_ptr<zmq::message_t> BufferConnection::Send(const void* data,
36  size_t size) {
37  zmq::message_t send_msg(data, size);
38  return Send(send_msg);
39 }
40 
41 } // namespace rpc
42 } // namespace io
43 } // namespace cloudViewer
int size
Generic file read and write utility for python interface.