ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
MessageProcessorBase.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 #include <io/rpc/Messages.h>
10 #include <io/rpc/ZMQContext.h>
11 
12 #include <zmq.hpp>
13 
14 using namespace cloudViewer::utility;
15 
16 namespace {
17 std::shared_ptr<zmq::message_t> CreateStatusMessage(
19  msgpack::sbuffer sbuf;
21  msgpack::pack(sbuf, reply);
22  msgpack::pack(sbuf, status);
23  std::shared_ptr<zmq::message_t> msg =
24  std::make_shared<zmq::message_t>(sbuf.data(), sbuf.size());
25 
26  return msg;
27 }
28 
29 template <class T>
30 std::shared_ptr<zmq::message_t> IgnoreMessage(
32  const T& msg,
33  const msgpack::object_handle& obj) {
34  LogInfo("MessageProcessorBase::ProcessMessage: messages with id {} will be "
35  "ignored",
36  msg.MsgId());
37  auto status =
39  status.str += ": messages with id " + msg.MsgId() + " are not supported";
40  return CreateStatusMessage(status);
41 }
42 
43 } // namespace
44 
45 namespace cloudViewer {
46 namespace io {
47 namespace rpc {
48 
49 MessageProcessorBase::MessageProcessorBase() {}
50 
51 MessageProcessorBase::~MessageProcessorBase() {}
52 
53 std::shared_ptr<zmq::message_t> MessageProcessorBase::ProcessMessage(
54  const messages::Request& req,
55  const messages::SetMeshData& msg,
56  const msgpack::object_handle& obj) {
57  return IgnoreMessage(req, msg, obj);
58 }
59 
60 std::shared_ptr<zmq::message_t> MessageProcessorBase::ProcessMessage(
61  const messages::Request& req,
62  const messages::GetMeshData& msg,
63  const msgpack::object_handle& obj) {
64  return IgnoreMessage(req, msg, obj);
65 }
66 
67 std::shared_ptr<zmq::message_t> MessageProcessorBase::ProcessMessage(
68  const messages::Request& req,
69  const messages::SetCameraData& msg,
70  const msgpack::object_handle& obj) {
71  return IgnoreMessage(req, msg, obj);
72 }
73 
74 std::shared_ptr<zmq::message_t> MessageProcessorBase::ProcessMessage(
75  const messages::Request& req,
76  const messages::SetProperties& msg,
77  const msgpack::object_handle& obj) {
78  return IgnoreMessage(req, msg, obj);
79 }
80 
81 std::shared_ptr<zmq::message_t> MessageProcessorBase::ProcessMessage(
82  const messages::Request& req,
83  const messages::SetActiveCamera& msg,
84  const msgpack::object_handle& obj) {
85  return IgnoreMessage(req, msg, obj);
86 }
87 
88 std::shared_ptr<zmq::message_t> MessageProcessorBase::ProcessMessage(
89  const messages::Request& req,
90  const messages::SetTime& msg,
91  const msgpack::object_handle& obj) {
92  return IgnoreMessage(req, msg, obj);
93 }
94 
95 } // namespace rpc
96 } // namespace io
97 } // namespace cloudViewer
#define LogInfo(...)
Definition: Logging.h:81
Generic file read and write utility for python interface.
struct for defining a "get_mesh_data" message, which requests mesh data.
Definition: Messages.h:410
std::string str
string representation of the code
Definition: Messages.h:541