Class: RemoteDroid::TriggerSubscriber

Inherits:
SPSSub
  • Object
show all
Defined in:
lib/remotedroid.rb

Instance Method Summary collapse

Constructor Details

#initialize(host: 'sps.home', drb_host: '127.0.0.1') ⇒ TriggerSubscriber



961
962
963
964
# File 'lib/remotedroid.rb', line 961

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/trigger') ⇒ Object



966
967
968
969
970
971
972
973
974
975
976
# File 'lib/remotedroid.rb', line 966

def subscribe(topic: 'macrodroid/trigger')
  
  super(topic: topic) do |msg|
    
    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/action: ' + msg }
    
  end        
end