1 require 'romp'
 2 
 3 class Bar
 4     attr_reader :i
 5     
 6     def initialize(i, romp)
 7         @i = i
 8         @romp = romp
 9     end
10     
11     def release()
12         @romp.delete_reference(self)
13     end
14 end
15 
16 class Foo < Bar
17     # Initialize @i to 0
18     def initialize(romp)
19         super(0, romp)
20         @romp = romp
21     end
22 
23     # Set @i
24     def foo(i)
25         @i = i
26     end
27 
28     # Return a reference to a new Bar object with Bar.i = @i + 1
29     def bar()
30         b = Bar.new(@i + 1, @romp)
31         obj = @romp.create_reference(b)
32         return obj
33     end
34 
35     # Test iteration
36     def each()
37         yield 1
38         yield 2
39         yield 3
40     end
41 
42     def throw_exception2()
43         raise RuntimeError
44     end
45 
46     # Test exception
47     def throw_exception()
48         throw_exception2()
49     end
50 end
51 
52 if ARGV.size > 1 or ARGV[0] == "-h" or ARGV[0] == '-H' then
53   puts <<END
54 Usage: #{$0} <url>
55 Example urls:
56   tcpromp://localhost:4242
57   udpromp://localhost:4242
58   unixromp:///tmp/foo
59 END
60 end
61 
62 url = ARGV[0] || "tcpromp://localhost:4242"
63 server = ROMP::Server.new(url, false)
64 
65 f = Foo.new(server)
66 server.bind(f, "foo")
67 server.thread.join