293 {
294 auto plugin_msg = std::make_shared<DvPluginMsg>();
295 if (!JsonStringToMessage(json_str, plugin_msg.get()).ok()) {
296 AERROR <<
"Failed to parse DvPluginMsg from json!";
297 return false;
298 }
299
300 if (!plugin_msg->has_target() || !plugin_msg->has_name()) {
301 AERROR <<
"Missing required field for DvPluginMsg.";
302 return false;
303 }
304 const string plugin_name = plugin_msg->target();
305 if (!CheckPluginStatus(plugin_name)) {
306 return false;
307 }
308 const string msg_name = plugin_msg->name();
309
310 if (plugins_[plugin_name].plugin_accept_msg.find(msg_name) ==
311 plugins_[plugin_name].plugin_accept_msg.end()) {
312 AERROR <<
"Plugin not accept this msg!";
313 return false;
314 }
315 const string channel_location =
316 plugins_[plugin_name].plugin_accept_msg[msg_name];
317 if (plugins_[plugin_name].writers.find(channel_location) ==
318 plugins_[plugin_name].writers.end()) {
319 AERROR <<
"The plugin does not support communication on this channel";
320 return false;
321 }
322 FillHeader("PluginManager", plugin_msg.get());
323 plugins_[plugin_name].writers[channel_location]->Write(plugin_msg);
324 return true;
325}