Class: RemoteDroid::TriggerSubscriber
- Inherits:
-
SPSSub
- Object
- SPSSub
- RemoteDroid::TriggerSubscriber
- Defined in:
- lib/remotedroid.rb
Instance Method Summary collapse
-
#initialize(host: 'sps.home', drb_host: '127.0.0.1') ⇒ TriggerSubscriber
constructor
A new instance of TriggerSubscriber.
- #subscribe(topic: 'macrodroid/#/trigger') ⇒ Object
Constructor Details
#initialize(host: 'sps.home', drb_host: '127.0.0.1') ⇒ TriggerSubscriber
Returns a new instance of TriggerSubscriber.
591 592 593 594 595 |
# File 'lib/remotedroid.rb', line 591 def initialize(host: 'sps.home', drb_host: '127.0.0.1') @remote = OneDrb::Client.new host: drb_host, port: '5777' super(host: host) puts 'TriggerSubscriber'.highlight end |
Instance Method Details
#subscribe(topic: 'macrodroid/#/trigger') ⇒ Object
597 598 599 600 601 602 603 604 605 606 607 608 609 610 |
# File 'lib/remotedroid.rb', line 597 def subscribe(topic: 'macrodroid/#/trigger') super(topic: topic) do |msg, topic| dev_id = topic.split('/')[1] trigger, json = msg.split(/:\s+/,2) a = @remote.trigger_fired trigger.to_sym, JSON.parse(json, symbolize_names: true) a.each {|msg| self.notice "macrodroid/%s/action: %s" % [dev_id, msg] } end end |