Class: DjiMqttConnect::Sys::Product::StatusTopicRepository
- Inherits:
-
TopicRepository
- Object
- TopicRepository
- DjiMqttConnect::Sys::Product::StatusTopicRepository
- Defined in:
- lib/dji_mqtt_connect/topics/sys/product/status.rb
Constant Summary collapse
- STATUS_TOPIC_REGEX =
/\Asys\/product\/(?<device_identifier>.+)\/status\z/
Instance Method Summary collapse
Methods inherited from TopicRepository
Constructor Details
This class inherits a constructor from DjiMqttConnect::TopicRepository
Instance Method Details
#listen! ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dji_mqtt_connect/topics/sys/product/status.rb', line 8 def listen! listen_to_topic("sys/product/+/status") do |topic, | logger.debug() matched_topic = STATUS_TOPIC_REGEX.match(topic) raise Error, "Unknown topic: #{topic}" unless matched_topic device_identifier = matched_topic[:device_identifier] = status_marshal.load() logger.info("Received #{} from #{device_identifier}") if .instance_of?(StatusMessage) # Broadcast an unsupported message event broadcast(:unsupported_message, topic, ) else # Build event name and broadcast (i.e. ::UpdateTopoStatusMessage => update_topo) broadcast(._method.to_sym, device_identifier, ) end rescue ParseError => error broadcast(:parse_error, error, topic, ) end end |