class RemoteDroid::TriggerSubscriber

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 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

Public Instance Methods

subscribe(topic: 'macrodroid/ click to toggle source
Calls superclass method
# 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