From 0819ebc96965b4ecf6e206de822dccc811d34b9b Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 11 Oct 2024 11:53:35 -0700 Subject: [PATCH] Fix websocket proto request handling (#281) Signed-off-by: Ian Chen (cherry picked from commit c60538a01b6e52fc6edc087bc2432fbd42f8c33a) --- 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