Y
yangpeng
[Note: parts of this message were removed to make it a legal post.]
I found a strange thing when I include a module to a Drb object.I'm confused.
server.rb:require 'drb'require 'module_a'
class ServerHello include TestModule1 def sayHello puts 'I am server' end endDRb.start_service("druby://127.0.0.1:2222", ServerHello.new)DRb.thread.join
client.rb:
require 'drb' require 'module_a' include TestModule1DRb.start_service info = DRbObject.new(nil, "druby://127.0.0.1:2222") info.sayHello() info.sayHello2
module_a.rb:
require 'drb'module TestModule1 def sayHello2 puts "who am i" endend
The three files in one path, I run server.rb first, then client.rb. The result is.server.rb output:I am serverclietn.rb output:who am iBut my expected result is:server.rb output both "I am server" and "who am i"
the "sayHello2" is executed in local, not remote..(or exactly, it's "client invoke server, server invoke client backly", for if we changed "puts "who am i"" to "puts self", the result is "DRbObject")
If I comments the "include TestModule1" of client.rb, the result is good.But this is not I want, for there are many standard code share between server and client.
It's it a defect or my usage error?
_________________________________________________________________
Windows Live Photo gallery ÊýÂëÏà»úµÄ³¬¼¶°é£¬ÇáËɹÜÀíºÍ±à¼ÕÕƬ£¬»¹ÄÜÖÆ×÷È«¾°ÃÀͼ£¡
http://get.live.cn/product/photo.html
I found a strange thing when I include a module to a Drb object.I'm confused.
server.rb:require 'drb'require 'module_a'
class ServerHello include TestModule1 def sayHello puts 'I am server' end endDRb.start_service("druby://127.0.0.1:2222", ServerHello.new)DRb.thread.join
client.rb:
require 'drb' require 'module_a' include TestModule1DRb.start_service info = DRbObject.new(nil, "druby://127.0.0.1:2222") info.sayHello() info.sayHello2
module_a.rb:
require 'drb'module TestModule1 def sayHello2 puts "who am i" endend
The three files in one path, I run server.rb first, then client.rb. The result is.server.rb output:I am serverclietn.rb output:who am iBut my expected result is:server.rb output both "I am server" and "who am i"
the "sayHello2" is executed in local, not remote..(or exactly, it's "client invoke server, server invoke client backly", for if we changed "puts "who am i"" to "puts self", the result is "DRbObject")
If I comments the "include TestModule1" of client.rb, the result is good.But this is not I want, for there are many standard code share between server and client.
It's it a defect or my usage error?
_________________________________________________________________
Windows Live Photo gallery ÊýÂëÏà»úµÄ³¬¼¶°é£¬ÇáËɹÜÀíºÍ±à¼ÕÕƬ£¬»¹ÄÜÖÆ×÷È«¾°ÃÀͼ£¡
http://get.live.cn/product/photo.html