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.
572 573 574 575 |
# File 'lib/remotedroid.rb', line 572 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
577 578 579 580 581 582 583 584 585 586 587 588 |
# File 'lib/remotedroid.rb', line 577 def subscribe(topic: 'macrodroid/action') super(topic: topic) do |msg| context, json = msg.split(/:\s+/,2) category, action = context.split('/',2) @remote.control.method(action.to_sym)\ .call(JSON.parse(json, symbolize_names: true)) end end |