From: m_seki@... Date: 2001-11-28T12:53:37+09:00 Subject: [ruby-talk:26734] Re: DRb and failing test, please give some insight... > I couldn't find any documentation which does not presuppose prior > knowledge of distributed objects and yet is something more than very > basic, would love to hear that something is in the works. (Yes, yes, > I know, I would already be writing it if I were able to.) I wrote a thin book. * http://www.ascii.co.jp/books/detail/4-7561/4-7561-3961-2.html (Distributed Object Programming by dRuby: (sorry, it is Japanese)) RWiki site: dRubyTut (Japanese, too) * http://www.jin.gr.jp/~nahi/RWiki/?cmd=view;name=dRubyTut Chad's tutorial (Yes, English) * http://www.chadfowler.com/ruby/drb.html > > FYI, drb-1.3.3b's 'drb/eq' has hash, and eql? methods. > > Pardon me... how does this relate to my Client/Server example? Server class in your example, manage clients by using Array. I'm worried about change Array to Hash . eg. | class Server | def initialize | @users = {} | end | def register(user) | @users[user] = Time.now | end | def online?(user) | @users.include? user | end | end The 'hash' method is called when compare hash keys. drb-1.3.2's 'drb/eq' will misstake. # test script: require 'drb/drb' def test_eq d1 = DRbObject.new(nil, 'druby://foo:12345') d2 = DRbObject.new(nil, 'druby://foo:12345') hash = {} hash[d1] = true p [(d1 == d2), hash.include?(d2)] end test_eq() # -> [false, false] # drb-1.3.2 drb/eq.rb module DRb class DRbObject def ==(other) return false unless DRbObject === other (@ref == other.__drbref) && (@uri == other.__drburi) end end end test_eq() # -> [true, false] # drb-1.3.3b drb/eq.rb module DRb class DRbObject def hash [@uri, @ref].hash end alias eql? == end end test_eq() # -> [true, true]