Class: RemoteDroid::ActionSubscriber
- Inherits:
-
SPSSub
- Object
- SPSSub
- RemoteDroid::ActionSubscriber
- Defined in:
- lib/remotedroid.rb
Instance Method Summary collapse
-
#initialize(host: 'sps.home', drb_host: '127.0.0.1') ⇒ ActionSubscriber
constructor
A new instance of ActionSubscriber.
- #subscribe(topic: 'macrodroid/action') ⇒ Object
Constructor Details
#initialize(host: 'sps.home', drb_host: '127.0.0.1') ⇒ ActionSubscriber
Returns a new instance of ActionSubscriber.
611 612 613 614 |
# File 'lib/remotedroid.rb', line 611 def initialize(host: 'sps.home', drb_host: '127.0.0.1') @remote = OneDrb::Client.new host: drb_host, port: '5777' super(host: host) end |
Instance Method Details
#subscribe(topic: 'macrodroid/action') ⇒ Object
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
# File 'lib/remotedroid.rb', line 616 def subscribe(topic: 'macrodroid/action') super(topic: topic) do |msg| context, json = msg.split(/:\s+/,2) category, action = context.split('/',2) h = JSON.parse(json, symbolize_names: true) if action == 'force_macro_run' and h[:serverside] then a = @remote.run_macro(h) a.each {|msg| self.notice 'macrodroid/action: ' + msg } else @remote.control.method(action.to_sym).call(h) end end end |