hack_night/solution/prob-7.rb in asir-0.2.0 vs hack_night/solution/prob-7.rb in asir-1.0.1
- old
+ new
@@ -1,34 +1,34 @@
# Use the Marshal and Base64 coders in prob-4.rb
$: << File.expand_path("../../../lib", __FILE__)
-require 'asir/transport/http'
+require 'asir/transport/webrick'
require 'asir/coder/marshal'
require 'asir/coder/base64'
require 'asir/coder/chain'
require 'math_service'
MathService.send(:include, ASIR::Client)
port = 3001
begin
- t = ASIR::Transport::HTTP.new(:uri => "http://localhost:#{port}/")
+ t = ASIR::Transport::Webrick.new(:uri => "http://localhost:#{port}/")
t._log_enabled = true
c = t.encoder = ASIR::Coder::Chain.new(:encoders =>
[
ASIR::Coder::Marshal.new,
ASIR::Coder::Base64.new,
])
c._log_enabled = true
server_pid = Process.fork do
- t.setup_webrick_server!
- t.start_webrick_server!
+ t.prepare_server!
+ t.run_server!
end
sleep 1 # wait for server to start
- MathService.client.transport = t
- MathService.client.sum([1, 2, 3])
+ MathService.asir.transport = t
+ MathService.asir.sum([1, 2, 3])
rescue Exception => err
$stderr.puts "ERROR: #{err.inspect}\n#{err.backtrace * "\n"}"
ensure
Process.kill(9, server_pid)
end