Class: DjiMqttConnect::Thing::Product::ServicesReplyTopicRepository
- Inherits:
-
DjiMqttConnect::TopicRepository
- Object
- DjiMqttConnect::TopicRepository
- DjiMqttConnect::Thing::Product::ServicesReplyTopicRepository
- Defined in:
- lib/dji_mqtt_connect/topics/thing/product/services_reply.rb
Constant Summary collapse
- SERVICES_REPLY_TOPIC_REGEX =
/\Athing\/product\/(?<gateway_sn>.+)\/services_reply\z/
Instance Method Summary collapse
Methods inherited from DjiMqttConnect::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 31 32 33 34 |
# File 'lib/dji_mqtt_connect/topics/thing/product/services_reply.rb', line 8 def listen! listen_to_topic("thing/product/+/services_reply") do |topic, | logger.debug() matched_topic = SERVICES_REPLY_TOPIC_REGEX.match(topic) raise Error, "Unknown topic: #{topic}" unless matched_topic gateway_sn = matched_topic[:gateway_sn] = services_reply_marshal.load() logger.info("Received #{} from #{gateway_sn}") # Broadcast a generic received services reply message event broadcast(:received_services_reply_message, gateway_sn, ) if .instance_of?(ServicesReplyMessage) # Broadcast an unsupported message event broadcast(:unsupported_message, topic, ) else # Build event name and broadcast (i.e. ::FlighttaskPrepareServicesReplyMessage => flighttask_prepare_reply) event_name = "#{._method.to_sym}_reply" broadcast(event_name, gateway_sn, ) end rescue ParseError => error broadcast(:parse_error, error, topic, ) end end |