# DRB Server
require 'drb'
class Collector
def initialize
@collection = []
end
def add(string)
puts "Adding [#{string}]"
@collection << string
end
def all
puts "Returning collection"
@collection.join(', ')
end
end
server = Collector.new
DRb.start_service(
"druby://:8887", server)
DRb.thread.join
|
| # DRB Client
require 'drb'
DRb.start_service
collector = DRbObject.new(
nil, "druby://:8887")
collector.add "Hello"
collector.add "World"
puts collector.all
|
|