Class: RemoteDroid::ResponseSubscriber

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') ⇒ ResponseSubscriber

Returns a new instance of ResponseSubscriber.



614
615
616
617
# File 'lib/remotedroid.rb', line 614

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



619
620
621
622
623
624
625
626
627
628
# File 'lib/remotedroid.rb', line 619

def subscribe(topic: 'macrodroid/response')
  
  super(topic: topic) do |msg|
    
    id, json = msg.split(/:\s+/,2)
    @remote.update id.to_sym, JSON.parse(json, symbolize_names: true)
    
  end
  
end