class RemoteDroid::ActionSubscriber
Public Class Methods
new(host: 'sps.home', drb_host: '127.0.0.1')
click to toggle source
Calls superclass method
# File lib/remotedroid.rb, line 617 def initialize(host: 'sps.home', drb_host: '127.0.0.1') @remote = OneDrb::Client.new host: drb_host, port: '5777' super(host: host) puts 'ActionSubscriber'.highlight end
Public Instance Methods
subscribe(topic: 'macrodroid/
click to toggle source
Calls superclass method
# File lib/remotedroid.rb, line 623 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 h[:serverside]then if action == 'force_macro_run' then a = @remote.run_macro(h) a.each {|msg| self.notice 'macrodroid/action: ' + msg } else puts 'action: ' + action.inspect puts 'h: ' + h.inspect r = @remote.local(action.to_sym, h) puts 'r: ' + r.inspect end else @remote.control.method(action.to_sym).call(h) end end end