Ruby 使用 DRb 启动远程对象服务
require "drb"require "drb_observer"
class Ticker
include DRbObservable
def initialize()
Thread.new { run }
end
def run
loop do
price = 10
print "Current price: #{price}\n"
notify_observers(Time.now, price)
sleep 1
end
end
end
ticker = Ticker.new()
DRb.start_service('druby://localhost:9001', ticker)
puts 'Press to exit.'
gets 没文字说明,这种习惯不好。
页:
[1]