A
Andre Nathan
Hi
I'm trying to find out how to use the DRbObservable module. This is
what I have so far:
--[ Server ]--
require 'drb/drb'
require 'drb/observer'
class Foo
include DRb:RbObservable
def run
changed
puts 'Notifying observer'
notify_observers('foo message')
end
end
DRb::start_service("druby://localhost:8888", Foo.new)
DRb::thread.join
--[ Client ]--
require 'drb/drb'
require 'drb/observer'
class Warner
def initialize(obj)
obj.add_observer(self)
end
def update(msg)
puts "Update message: #{msg}"
end
end
DRb.start_service
obj = DRbObject.new(nil, 'druby://localhost:8888')
Warner.new(obj)
obj.run
This is the error I get when I run the client after starting the
server:
$ ruby client.rb
(druby://localhost:8888) /usr/local/lib/ruby/1.8/observer.rb:126:in
`add_observer': observer needs to respond to `update' (NoMethodError)
from b.rb:6:in `initialize'
from b.rb:15:in `new'
from b.rb:15
I don't understand it, since I've defined an 'update' method... can
anyone help me on that?
Thanks
Andre
I'm trying to find out how to use the DRbObservable module. This is
what I have so far:
--[ Server ]--
require 'drb/drb'
require 'drb/observer'
class Foo
include DRb:RbObservable
def run
changed
puts 'Notifying observer'
notify_observers('foo message')
end
end
DRb::start_service("druby://localhost:8888", Foo.new)
DRb::thread.join
--[ Client ]--
require 'drb/drb'
require 'drb/observer'
class Warner
def initialize(obj)
obj.add_observer(self)
end
def update(msg)
puts "Update message: #{msg}"
end
end
DRb.start_service
obj = DRbObject.new(nil, 'druby://localhost:8888')
Warner.new(obj)
obj.run
This is the error I get when I run the client after starting the
server:
$ ruby client.rb
(druby://localhost:8888) /usr/local/lib/ruby/1.8/observer.rb:126:in
`add_observer': observer needs to respond to `update' (NoMethodError)
from b.rb:6:in `initialize'
from b.rb:15:in `new'
from b.rb:15
I don't understand it, since I've defined an 'update' method... can
anyone help me on that?
Thanks
Andre