51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/cosmos/topics/router_topic.rb', line 51
def self.route_command(packet, target_names, scope:)
if packet.identified?
topic = "{#{scope}__CMD}TARGET__#{packet.target_name}"
Topic.write_topic(topic, { 'target_name' => packet.target_name, 'cmd_name' => packet.packet_name, 'cmd_buffer' => packet.buffer(false) }, '*', 100)
elsif target_names.length == 1
topic = "{#{scope}__CMD}TARGET__#{target_names[0]}"
Topic.write_topic(topic, { 'target_name' => packet.target_name, 'cmd_name' => 'UNKNOWN', 'cmd_buffer' => packet.buffer(false) }, '*', 100)
else
raise "No route for command: #{packet.target_name} #{packet.packet_name}"
end
end
|