Hi,
I''m trying to get a simple ROR and DRb program to work and I have a
question about how ROR works.
My application has a server and a client which is part of a ROR
application. The server is simple enough and it has one function:
def do_something(listener)
add_observer(listener)
puts ''message on the server''
end
The ROR application has one controller which calls the do_something
function when a button is pressed on the page. I placed the
DRb.start_service() and DRbObject.new() functions in evironment.rb and
I placed the reference to the remote object into a global variable.
The controller would then simply call:
$rem_obj.do_something(listener). listener is an instance of a Listener
class which looks like this:
class Listener
include DRbUndumped
def update(rhost_name, exit_value)
puts ''message received from the host''
end
end
The problem that I''m having is that an observer (the listener object
in this case) should be running at all times after the registration
(add_observer in do_something) with the remote object. I read that ROR
is not multithreaded (and thus I learned about backgroundrb), and it
cannot listen to both web requests and updates from the server. How
can it even keep listener running?. Indeed, I get "DRb::DRbConnError",
druby://localhost:42531 - #<Errno::ECONNREFUSED: Connection refused -
connect(2)>, in add_observer on the client.
The strange part is that I put DRb.start_service() in the initialize()
function of the controller and it magically works. How is this
possible? Upon a page request, after initialize() is called and the
request gets serviced, how does the server still have a reference to
listener? I cannot believe that listener runs in a different thread,
because I didn''t create one and the framework didn''t provide
one.
Thanks,
Tiberiu
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---