| $:.unshift '../../lib/rb/lib' |
| require 'thrift/protocol/binaryprotocol' |
| transport = Thrift::BufferedTransport.new(Thrift::Socket.new('localhost', port)) |
| protocol = Thrift::BinaryProtocol.new(transport) |
| client = Calculator::Client.new(protocol) |
| work.op = Operation::SUBTRACT |
| diff = client.calculate(1, work) |
| print "15-10=", diff, "\n" |
| log = client.getStruct(1) |
| print "Log: ", log.value, "\n" |
| work.op = Operation::DIVIDE |
| quot = client.calculate(1, work) |
| puts "Whoa, we can divide by 0 now?" |
| rescue InvalidOperation => io |
| print "InvalidOperation: ", io.why, "\n" |
| rescue Thrift::Exception => tx |
| print 'Thrift::Exception: ', tx.message, "\n" |