| Class | Rinda::RingServer |
| In: |
rinda/ring.rb
|
| Parent: | Object |
A RingServer allows a Rinda::TupleSpace to be located via UDP broadcasts. Service location uses the following steps:
Advertises ts on the UDP broadcast address at port.
# File rinda/ring.rb, line 32 def initialize(ts, port=Ring_PORT) @ts = ts @soc = UDPSocket.open @soc.bind('', port) @w_service = write_service @r_service = reply_service end
Pulls lookup tuples out of the TupleSpace and sends their DRb object the address of the local TupleSpace.
# File rinda/ring.rb, line 82 def do_reply tuple = @ts.take([:lookup_ring, nil]) Thread.new { tuple[1].call(@ts) rescue nil} rescue end
Extracts the response URI from msg and adds it to TupleSpace where it will be picked up by reply_service for notification.
# File rinda/ring.rb, line 57 def do_write(msg) Thread.new do begin tuple, sec = Marshal.load(msg) @ts.write(tuple, sec) rescue end end end
Creates a thread that notifies waiting clients from the TupleSpace.
# File rinda/ring.rb, line 70 def reply_service Thread.new do loop do do_reply end end end
ruby-doc.org is a community service provided by Happy Camper Studios, a Phoenix, Arizona, Ruby application development company.
Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.
For more information on the Ruby programming language, visit ruby-lang.org.
Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.