From 60c7943d87635655caed12e133ffacdd0668015d Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:54:30 -0600 Subject: [PATCH] Fix websocket proto request handling (#281) (#283) Signed-off-by: Ian Chen (cherry picked from commit c60538a01b6e52fc6edc087bc2432fbd42f8c33a) Co-authored-by: Ian Chen --- plugins/websocket_server/WebsocketServer.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/websocket_server/WebsocketServer.cc b/plugins/websocket_server/WebsocketServer.cc index ee768c8..a828c84 100644 --- a/plugins/websocket_server/WebsocketServer.cc +++ b/plugins/websocket_server/WebsocketServer.cc @@ -742,10 +742,21 @@ void WebsocketServer::OnMessage(int _socketId, const std::string _msg) // Get all the messages, and build a single proto to send to the client. for (auto const &type : types) { + // only include messages in the gz.msgs package + if (type.find("gz.msgs") != 0) + continue; auto msg = gz::msgs::Factory::New(type); if (msg) { auto descriptor = msg->GetDescriptor(); + + // Skip nested messages for now, e.g. gz.msgs.CameraInfo.Distortion + // conflicts with gz.msgs.Distortion - in both cases the DebugString + // will output the same message name: "message Distortion {..}". + // todo(iche033): extend the logic to work with nested messages + if (descriptor->containing_type()) + continue; + if (descriptor) allProtos += descriptor->DebugString(); else