summaryrefslogtreecommitdiff
path: root/jni/ruby/sample/drb/ring_echo.rb
blob: 3b743cab8ee0ee862c537ca661e1ea21a4e61cef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'drb/drb'
require 'drb/eq'
require 'rinda/ring'
require 'thread'

class RingEcho
  include DRbUndumped
  def initialize(name)
    @name = name
  end

  def echo(str)
    "#{@name}: #{str}"
  end
end

DRb.start_service

renewer = Rinda::SimpleRenewer.new

finder = Rinda::RingFinger.new
ts = finder.lookup_ring_any
ts.read_all([:name, :RingEcho, nil, nil]).each do |tuple|
  p tuple[2]
  puts tuple[2].echo('Hello, World') rescue nil
end
ts.write([:name, :RingEcho, RingEcho.new(DRb.uri), ''], renewer)

DRb.thread.join