Method: Fancybox2::Module::Base#on_client_connack
- Defined in:
- lib/fancybox2/module/base.rb
#on_client_connack ⇒ Object
MQTT Client callbacks
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/fancybox2/module/base.rb', line 281 def on_client_connack logger.debug 'Connected to the broker' # Setup default callbacks default_actions.each do |action_name, callback| action_name = action_name.to_s on_action action_name do |packet| # :nocov: if callback.is_a? Proc callback.call packet else logger.warn "No valid callback defined for '#{action_name}'" end # :nocov: end end if mqtt_client.subscribed_topics.size.zero? # Subscribe to all messages directed to me logger.debug 'Making broker subscriptions' mqtt_client.subscribe [topic_for(source: '+', action: '+'), 2] end end |