Sha256: 8d9b4ab4e9d97946dd4347b30e2b2897b42d024dfca3dbc28f792c0dac403677

Contents?: true

Size: 915 Bytes

Versions: 2

Compression:

Stored size: 915 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8

$LOAD_PATH.unshift File.expand_path("../../../lib", __FILE__)

require "rpc"

RPC.logging = true

client = RPC::Client.setup("http://127.0.0.1:8081")

# Get result of an existing method.
puts "Server timestamp is #{client.server_timestamp}"

# Get result of a non-existing method via method_missing.
puts "Method missing works: #{client + 1}"

# Synchronous error handling.
begin
  client.buggy_method
rescue Exception => exception
  STDERR.puts "EXCEPTION CAUGHT: #{exception.inspect}"
end

# Notification isn't supported, because HTTP works in
# request/response mode, so it does behave in the same
# manner as RPC via method_missing. Sense of this is
# only to check, that it won't blow up.
puts "Sending a notification ..."
client.notification(:log, "Some shit.")

# Batch.
result = client.batch([[:log, ["Message"], nil], [:a_method, []]])
puts "Batch result: #{result}"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sync_service-0.1.0 lib/rpc/examples/net-http-json/client.rb
sync_service-0.0.8 lib/rpc/examples/net-http-json/client.rb