Object
Session is a abstract class corresponds with a remote host. You can call remote method using call, call_async, callback or notify method.
# File lib/msgpack/rpc/session.rb, line 25
25: def initialize(builder, address, loop)
26: @address = address
27: @loop = loop
28: @reqtable = {}
29: @timeout = 10 # FIXME default timeout time
30: @seqid = 0
31: @transport = builder.build_transport(self, address)
32: end
Calls remote method. This method is same as call_async(method, *args).get
# File lib/msgpack/rpc/session.rb, line 53
53: def call(method, *args)
54: send_request(method, args).get
55: end
Calls remote method. This method is same as call(method, *args) excepting that the arugment is a array.
# File lib/msgpack/rpc/session.rb, line 63
63: def call_apply(method, params)
64: send_request(method, params).get
65: end
Calls remote method asynchronously. This method is non-blocking and returns Future.
# File lib/msgpack/rpc/session.rb, line 72
72: def call_async(method, *args)
73: future = send_request(method, args)
74: end
Calls remote method asynchronously. This method is same as call_async(method, *args) excepting that the arugment is a array.
# File lib/msgpack/rpc/session.rb, line 82
82: def call_async_apply(method, params)
83: future = send_request(method, params)
84: end
Calls remote method asynchronously. The callback method is called with Future when the result is reached. This method is same as call_async(method, *args).attach_callback {|future| }
# File lib/msgpack/rpc/session.rb, line 102
102: def callback(method, *args, &block)
103: future = send_request(method, args)
104: future.attach_callback(block)
105: future
106: end
Calls remote method asynchronously. The callback method is called with Future when the result is reached. This method is same as callback(method, *args).attach_callback {|future| } excepting that the argument is a array.
# File lib/msgpack/rpc/session.rb, line 115
115: def callback_apply(method, params, &block)
116: future = send_request(method, params)
117: future.attach_callback(block)
118: future
119: end
Closes underlaying Transport and destroy resources.
# File lib/msgpack/rpc/session.rb, line 146
146: def close
147: @transport.close
148: @reqtable = {}
149: @seqid = 0
150: self
151: end
Calls remote method with NOTIFY protocol. It doesn’t require server to return results. This method is non-blocking and returns nil.
# File lib/msgpack/rpc/session.rb, line 127
127: def notify(method, *args)
128: send_notify(method, args)
129: nil
130: end
Calls remote method with NOTIFY protocol. It doesn’t require server to return results. This method is non-blocking and returns nil. This method is same as notify(method, *args) excepting that the argument is a array.
# File lib/msgpack/rpc/session.rb, line 140
140: def notify_apply(method, params)
141: send_notify(method, params)
142: nil
143: end
# File lib/msgpack/rpc/session.rb, line 88
88: def send(method, *args)
89: if caller.first =~ /.*_test.rb/ || caller.first =~ /.*_spec.rb/ then
90: warn "\n Don't use send method. Use 'call_async' method."
91: end
92: call_async(method, *args)
93: end
backward compatibility
# File lib/msgpack/rpc/session.rb, line 194
194: def send_notify(method, param)
195: method = method.to_s
196: data = [NOTIFY, method, param].to_msgpack
197: @transport.send_data(data)
198: nil
199: end
# File lib/msgpack/rpc/session.rb, line 185
185: def send_request(method, param)
186: method = method.to_s
187: msgid = @seqid
188: @seqid += 1; if @seqid >= 1<<31 then @seqid = 0 end
189: data = [REQUEST, msgid, method, param].to_msgpack
190: @transport.send_data(data)
191: @reqtable[msgid] = Future.new(self, @loop)
192: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.