msgpack-rpc 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/msgpack/rpc.rb +34 -13
- metadata +2 -2
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ DESCRIPTION = "RPC library using MessagePack, a ainary-based efficient dat
|
|
17
17
|
RUBYFORGE_PROJECT = "msgpack"
|
18
18
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
19
19
|
BIN_FILES = %w( )
|
20
|
-
VERS = "0.1.
|
20
|
+
VERS = "0.1.4"
|
21
21
|
|
22
22
|
#REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
23
23
|
REV = nil
|
data/lib/msgpack/rpc.rb
CHANGED
@@ -165,18 +165,13 @@ class ClientSession
|
|
165
165
|
|
166
166
|
class BasicRequest
|
167
167
|
def initialize(session, loop)
|
168
|
-
@error = nil
|
169
|
-
@result = nil
|
170
168
|
@session = session
|
171
169
|
@timeout = session.timeout
|
172
170
|
@loop = loop
|
173
171
|
end
|
174
172
|
attr_reader :loop
|
175
|
-
attr_accessor :result, :error
|
176
173
|
|
177
174
|
def call(err, res)
|
178
|
-
@error = err
|
179
|
-
@result = res
|
180
175
|
@session = nil
|
181
176
|
end
|
182
177
|
|
@@ -197,6 +192,32 @@ class ClientSession
|
|
197
192
|
end
|
198
193
|
end
|
199
194
|
|
195
|
+
class AsyncRequest < BasicRequest
|
196
|
+
def initialize(session, loop)
|
197
|
+
super(session, loop)
|
198
|
+
@error = nil
|
199
|
+
@result = nil
|
200
|
+
end
|
201
|
+
attr_accessor :result, :error
|
202
|
+
|
203
|
+
def call(err, res)
|
204
|
+
@error = err
|
205
|
+
@result = res
|
206
|
+
@session = nil
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
class CallbackRequest < BasicRequest
|
211
|
+
def initialize(session, loop, block)
|
212
|
+
super(session, loop)
|
213
|
+
@block = block
|
214
|
+
end
|
215
|
+
|
216
|
+
def call(err, res)
|
217
|
+
@block.call(err, res)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
200
221
|
|
201
222
|
def initialize(loop)
|
202
223
|
@sock = nil
|
@@ -212,11 +233,11 @@ class ClientSession
|
|
212
233
|
end
|
213
234
|
|
214
235
|
def send(method, *args)
|
215
|
-
send_real(method, args,
|
236
|
+
send_real(method, args, AsyncRequest.new(self,@loop))
|
216
237
|
end
|
217
238
|
|
218
239
|
def callback(method, *args, &block)
|
219
|
-
send_real(method, args, block)
|
240
|
+
send_real(method, args, CallbackRequest.new(self,@loop,block))
|
220
241
|
end
|
221
242
|
|
222
243
|
def call(method, *args)
|
@@ -320,7 +341,7 @@ end
|
|
320
341
|
class ServerSession
|
321
342
|
def initialize(obj, accept = obj.public_methods)
|
322
343
|
@obj = obj
|
323
|
-
@accept = accept.map {|m| m.to_s
|
344
|
+
@accept = accept.map {|m| m.is_a?(Integer) ? m : m.to_s}
|
324
345
|
end
|
325
346
|
|
326
347
|
def add_socket(sock)
|
@@ -389,8 +410,8 @@ module LoopUtil
|
|
389
410
|
|
390
411
|
def stop
|
391
412
|
@loop.stop
|
392
|
-
# attach
|
393
|
-
@loop.attach
|
413
|
+
# attach dummy timer
|
414
|
+
@loop.attach Rev::TimerWatcher.new(0, false)
|
394
415
|
nil
|
395
416
|
end
|
396
417
|
end
|
@@ -411,8 +432,8 @@ class Client
|
|
411
432
|
attr_reader :host, :port
|
412
433
|
|
413
434
|
def close
|
414
|
-
@timer.detach
|
415
|
-
@rsock.detach
|
435
|
+
@timer.detach if @timer.attached?
|
436
|
+
@rsock.detach if @rsock.attached?
|
416
437
|
@s.close
|
417
438
|
nil
|
418
439
|
end
|
@@ -468,7 +489,7 @@ class Server
|
|
468
489
|
|
469
490
|
def close
|
470
491
|
@socks.reject! {|lsock|
|
471
|
-
lsock.detach
|
492
|
+
lsock.detach if lsock.attached?
|
472
493
|
lsock.close
|
473
494
|
true
|
474
495
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgpack-rpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FURUHASHI Sadayuki
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-01 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|