class RemoteDroid::ResponseSubscriber

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 663
def initialize(host: 'sps.home', drb_host: '127.0.0.1')
  @remote = OneDrb::Client.new host: drb_host, port: '5777'    
  super(host: host)
  puts 'ResponseSubscriber'.highlight
end

Public Instance Methods

subscribe(topic: 'macrodroid/ click to toggle source
Calls superclass method
# File lib/remotedroid.rb, line 669
def subscribe(topic: 'macrodroid/#/response')
  
  super(topic: topic) do |msg|
    
    #puts 'msg: ' + msg.inspect
    json, id = msg.split(/:\s+/,2).reverse
    
    h = JSON.parse(json, symbolize_names: true)
    id ||= h.keys.first
    #puts '->' + [id, h].inspect
    @remote.update id.to_sym, h
    
  end
  
end