pipe_rpc 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pipe_rpc/gateway.rb +10 -2
- data/lib/pipe_rpc/hub_socket.rb +15 -3
- data/lib/pipe_rpc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee330bfeecf7d6643745bba563427b7ef8f80b13
|
4
|
+
data.tar.gz: e3b940e58c316efe2bde2a9165bd6d692c113abf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beaff9f942564a862ec5923ad37b88dbd7e20896d2124c1b2dbcf681611dcac51f5bf180746f80f5678548a7ce80a36e0bce2b927d9b1dd8a64d9724cbb53a3d
|
7
|
+
data.tar.gz: 47329a0a0b9024a6ca3cc922350bcb26837503a94d77641f01b83b7880c80f5f90a476718644f86f62c8b703c5aafa9c9d4e757460da3be34c2949140ffd3f1b
|
data/lib/pipe_rpc/gateway.rb
CHANGED
@@ -24,12 +24,20 @@ module PipeRpc
|
|
24
24
|
@hub.socket.on_sent(&on_sent)
|
25
25
|
end
|
26
26
|
|
27
|
+
def off_sent(on_sent)
|
28
|
+
@hub.socket.off_sent(on_sent)
|
29
|
+
end
|
30
|
+
|
27
31
|
def on_received(&on_received)
|
28
32
|
@hub.socket.on_received(&on_received)
|
29
33
|
end
|
30
34
|
|
31
|
-
def
|
32
|
-
@hub.socket.
|
35
|
+
def off_received(on_received)
|
36
|
+
@hub.socket.off_received(on_received)
|
37
|
+
end
|
38
|
+
|
39
|
+
def close(reason = 'manually closed')
|
40
|
+
@hub.socket.close(reason)
|
33
41
|
end
|
34
42
|
|
35
43
|
def handle_message
|
data/lib/pipe_rpc/hub_socket.rb
CHANGED
@@ -6,10 +6,11 @@ module PipeRpc
|
|
6
6
|
@output = args.fetch(:output)
|
7
7
|
@on_sent = []
|
8
8
|
@on_received = []
|
9
|
+
@closed_reason = "lost connection to other side"
|
9
10
|
end
|
10
11
|
|
11
12
|
def read
|
12
|
-
raise ClosedError if @input.closed?
|
13
|
+
raise ClosedError.new(@closed_reason) if @input.closed?
|
13
14
|
|
14
15
|
# infinite #readpartial that also works with mruby-restricted_io
|
15
16
|
packed = ''
|
@@ -26,7 +27,7 @@ module PipeRpc
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def write(obj)
|
29
|
-
raise ClosedError if @output.closed?
|
30
|
+
raise ClosedError.new(@closed_reason) if @output.closed?
|
30
31
|
payload = obj.to_h
|
31
32
|
@on_sent.each{ |callback| callback.call(payload) }
|
32
33
|
@output.syswrite payload.to_msgpack
|
@@ -34,13 +35,24 @@ module PipeRpc
|
|
34
35
|
|
35
36
|
def on_sent(&on_sent)
|
36
37
|
@on_sent << on_sent
|
38
|
+
on_sent
|
39
|
+
end
|
40
|
+
|
41
|
+
def off_sent(callback)
|
42
|
+
@on_sent.delete(callback)
|
37
43
|
end
|
38
44
|
|
39
45
|
def on_received(&on_received)
|
40
46
|
@on_received << on_received
|
47
|
+
on_received
|
48
|
+
end
|
49
|
+
|
50
|
+
def off_received(callback)
|
51
|
+
@on_received.delete(callback)
|
41
52
|
end
|
42
53
|
|
43
|
-
def close
|
54
|
+
def close(reason)
|
55
|
+
@closed_reason = reason
|
44
56
|
@input.close
|
45
57
|
@output.close
|
46
58
|
end
|
data/lib/pipe_rpc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipe_rpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Aue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|