From a4063948e7b6ac4b07370bfd2e5a72b5372c3787 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Mon, 29 Mar 2021 14:48:26 -0700 Subject: [PATCH 1/3] Support particle_emitters in the websocket server Signed-off-by: Nate Koenig --- plugins/websocket_server/WebsocketServer.cc | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/plugins/websocket_server/WebsocketServer.cc b/plugins/websocket_server/WebsocketServer.cc index 6b535543..206a22a5 100644 --- a/plugins/websocket_server/WebsocketServer.cc +++ b/plugins/websocket_server/WebsocketServer.cc @@ -748,6 +748,37 @@ void WebsocketServer::OnMessage(int _socketId, const std::string &_msg) this->QueueMessage(this->connections[_socketId].get(), data.c_str(), data.length()); } + /// \todo(nkoeng) Deprecate this in Ignition Fortress, and instruct users + /// to rely on the "scene" message. + else if (frameParts[0] == "particle_emitters") + { + igndbg << "Particle emitter request recieved for world[" + << frameParts[1] << "]\n"; + ignition::msgs::Empty req; + req.set_unused(true); + + ignition::msgs::ParticleEmitter_V rep; + bool result; + unsigned int timeout = 2000; + + std::string serviceName = std::string("/world/") + frameParts[1] + + "/particle_emitters"; + + bool executed = this->node.Request(serviceName, req, timeout, rep, result); + if (!executed || !result) + { + ignerr << "Failed to get the particle emitter information for " + << frameParts[1] << " world.\n"; + } + + std::string data = BUILD_MSG(this->operations[PUBLISH], frameParts[0], + std::string("ignition.msgs.ParticleEmitter_V"), + rep.SerializeAsString()); + + // Queue the message for delivery. + this->QueueMessage(this->connections[_socketId].get(), + data.c_str(), data.length()); + } else if (frameParts[0] == "sub") { // Store the relation of socketId to subscribed topic. From b3b46a8e1866f8e36b1117f2a89db2cb8cfb8af4 Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Tue, 30 Mar 2021 13:14:08 -0700 Subject: [PATCH 2/3] update documentation Signed-off-by: Nate Koenig --- plugins/websocket_server/WebsocketServer.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/websocket_server/WebsocketServer.hh b/plugins/websocket_server/WebsocketServer.hh index 484cdddb..dcd69de1 100644 --- a/plugins/websocket_server/WebsocketServer.hh +++ b/plugins/websocket_server/WebsocketServer.hh @@ -85,9 +85,10 @@ namespace ignition /// 1. "sub": Subscribe to the topic in the `topic_name` component, /// 2. "pub": Publish a message from the Ignition Transport topic in /// the `topic_name` component, - /// 3. "topics": Get the list of available topics, and + /// 3. "topics": Get the list of available topics, /// 4. "protos": Get a string containing all the protobuf - /// definitions. + /// definitions, and + /// 5. "particle_emitters": Get the list of particle emitters. /// /// The `topic_name` component is mandatory for the "sub" and "pub" /// operations. If present, it must be the name of an Ignition Transport From c404a076c9d40561bafa4371e4b2f2e7225ed4cf Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Mon, 12 Apr 2021 08:12:23 -0700 Subject: [PATCH 3/3] Spelling Signed-off-by: Nate Koenig --- plugins/websocket_server/WebsocketServer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/websocket_server/WebsocketServer.cc b/plugins/websocket_server/WebsocketServer.cc index 206a22a5..4bf99d99 100644 --- a/plugins/websocket_server/WebsocketServer.cc +++ b/plugins/websocket_server/WebsocketServer.cc @@ -752,7 +752,7 @@ void WebsocketServer::OnMessage(int _socketId, const std::string &_msg) /// to rely on the "scene" message. else if (frameParts[0] == "particle_emitters") { - igndbg << "Particle emitter request recieved for world[" + igndbg << "Particle emitter request received for world[" << frameParts[1] << "]\n"; ignition::msgs::Empty req; req.set_unused(true);