Method: OpenC3::InterfaceTopic.receive_commands

Defined in:
lib/openc3/topics/interface_topic.rb

.receive_commands(interface, scope:) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/openc3/topics/interface_topic.rb', line 39

def self.receive_commands(interface, scope:)
  while true
    Topic.read_topics(InterfaceTopic.topics(interface, scope: scope)) do |topic, msg_id, msg_hash, redis|
      result = yield topic, msg_id, msg_hash, redis
      ack_topic = topic.split("__")
      ack_topic[1] = 'ACK' + ack_topic[1]
      ack_topic = ack_topic.join("__")
      Topic.write_topic(ack_topic, { 'result' => result, 'id' => msg_id }, '*', 100)
    end
  end
end