Ruby 使用 DRb 启动远程对象服务

2014-10-26 0 282
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 [return] to exit.'
gets

遇见资源网 ruby Ruby 使用 DRb 启动远程对象服务 http://www.ox520.com/16159.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务