Mark Slee | 02d1edc | 2007-03-07 05:17:25 +0000 | [diff] [blame] | 1 | #!/usr/bin/env ruby |
Mark Slee | 157d9f7 | 2007-02-07 06:03:53 +0000 | [diff] [blame] | 2 | |
| 3 | $:.push('gen-rb') |
| 4 | $:.push('../../lib/rb/lib') |
| 5 | |
| 6 | require 'thrift/transport/tsocket' |
| 7 | require 'thrift/protocol/tbinaryprotocol' |
| 8 | require 'thrift/server/tserver' |
| 9 | require 'ThriftTest' |
| 10 | |
| 11 | class TestHandler |
| 12 | include ThriftTest::Iface |
| 13 | |
| 14 | def testVoid() |
| 15 | print "testVoid()\n" |
| 16 | end |
| 17 | |
| 18 | def testString(thing) |
| 19 | print "testString(#{thing})\n" |
| 20 | return thing |
| 21 | end |
| 22 | |
| 23 | def testByte(thing) |
| 24 | print "testByte(#{thing})\n" |
| 25 | return thing |
| 26 | end |
| 27 | |
| 28 | def testI32(thing) |
| 29 | print "testI32(#{thing})\n" |
| 30 | return thing |
| 31 | end |
| 32 | |
| 33 | def testI64(thing) |
| 34 | print "testI64(#{thing})\n" |
| 35 | return thing |
| 36 | end |
| 37 | |
| 38 | def testDouble(thing) |
| 39 | print "testDouble(#{thing})\n" |
| 40 | return thing |
| 41 | end |
| 42 | |
| 43 | def testStruct(thing) |
| 44 | print "testStruct(#{thing})\n" |
| 45 | return thing |
| 46 | end |
| 47 | |
| 48 | def testMap(thing) |
| 49 | print "testMap(#{thing})\n" |
| 50 | return thing |
| 51 | end |
| 52 | |
| 53 | def testSet(thing) |
| 54 | print "testSet(#{thing})\n" |
| 55 | return thing |
| 56 | end |
| 57 | |
| 58 | def testList(thing) |
| 59 | print "testList(#{thing})\n" |
| 60 | return thing |
| 61 | end |
| 62 | |
Mark Slee | 477a580 | 2007-06-30 01:18:12 +0000 | [diff] [blame^] | 63 | def testNest(thing) |
| 64 | print "testNest(#{thing})\n" |
| 65 | puts " i32_thing: #{thing.i32_thing}" |
| 66 | puts " with struct: " |
| 67 | %w{ string_thing byte_thing i32_thing }.each do |t| |
| 68 | puts " #{t}: #{thing.struct_thing.send(t)}" |
| 69 | end |
| 70 | return thing |
| 71 | end |
| 72 | |
Mark Slee | 157d9f7 | 2007-02-07 06:03:53 +0000 | [diff] [blame] | 73 | end |
| 74 | |
| 75 | handler = TestHandler.new() |
| 76 | processor = ThriftTest::Processor.new(handler) |
| 77 | transport = TServerSocket.new(9090) |
| 78 | server = TSimpleServer.new(processor, transport) |
| 79 | server.serve() |