Class: RemoteDroid::ResponseSubscriber
- Inherits:
-
SPSSub
- Object
- SPSSub
- RemoteDroid::ResponseSubscriber
- Defined in:
- lib/remotedroid.rb
Instance Method Summary collapse
-
#initialize(host: 'sps.home', drb_host: '127.0.0.1') ⇒ ResponseSubscriber
constructor
A new instance of ResponseSubscriber.
- #subscribe(topic: 'macrodroid/response') ⇒ Object
Constructor Details
#initialize(host: 'sps.home', drb_host: '127.0.0.1') ⇒ ResponseSubscriber
Returns a new instance of ResponseSubscriber.
1004 1005 1006 1007 |
# File 'lib/remotedroid.rb', line 1004 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
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 |
# File 'lib/remotedroid.rb', line 1009 def subscribe(topic: 'macrodroid/response') super(topic: topic) do |msg| json, id = msg.split(/:\s+/,2).reverse h = JSON.parse(json, symbolize_names: true) id ||= h.keys.first @remote.update id.to_sym, h end end |