simplerpc 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/lib/simplerpc/client.rb +2 -1
- data/lib/simplerpc/server.rb +8 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35e03bbef72aa8b10a3ce67964e8ad2ae5a0a59d
|
4
|
+
data.tar.gz: b961f842f95b6b1e9b784bbb287c9a493b9ccb0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c681277ce02e0857e4feb5e7ac937bb13fa28d6f7451914eecfcf46968631c35d2c491210aa89a4cb97bc0fefe3f15ed40ad0e8a492cd57f28a635505c329ed7
|
7
|
+
data.tar.gz: de1c8efba094eea904384d94478f8d891387631cf8bd93684174ef389fa7e7f6c2155fab8bb4c4f5a72ad67c198606ce76a311d494844a6de411da607e23b96c
|
data/lib/simplerpc/client.rb
CHANGED
data/lib/simplerpc/server.rb
CHANGED
@@ -11,15 +11,15 @@ module SimpleRPC
|
|
11
11
|
|
12
12
|
# Create a new server for a given proxy object
|
13
13
|
#
|
14
|
-
#
|
14
|
+
# obj:: The object to proxy the API for---any ruby object
|
15
15
|
# port:: The port to listen on
|
16
16
|
# hostname:: The ip of the interface to listen on, or nil for all
|
17
17
|
# serialiser:: The serialiser to use
|
18
18
|
# threaded:: Should the server support multiple clients at once?
|
19
19
|
# timeout:: Socket timeout
|
20
|
-
def initialize(
|
21
|
-
@
|
22
|
-
@port
|
20
|
+
def initialize(obj, port, hostname=nil, serialiser=Serialiser.new, threaded=false, timeout=nil)
|
21
|
+
@obj = obj
|
22
|
+
@port = port
|
23
23
|
@hostname = hostname
|
24
24
|
|
25
25
|
# What format to use.
|
@@ -60,11 +60,11 @@ module SimpleRPC
|
|
60
60
|
thread = Thread.new(id, @m, @s.accept){|id, m, c|
|
61
61
|
handle_client(c)
|
62
62
|
|
63
|
-
puts "#{id} closing 1"
|
63
|
+
# puts "#{id} closing 1"
|
64
64
|
m.synchronize{
|
65
65
|
@clients.delete(id)
|
66
66
|
}
|
67
|
-
puts "#{id} closing 2"
|
67
|
+
# puts "#{id} closing 2"
|
68
68
|
}
|
69
69
|
|
70
70
|
# Add to the client list
|
@@ -109,14 +109,14 @@ module SimpleRPC
|
|
109
109
|
m, arity = recv(c)
|
110
110
|
|
111
111
|
# Check the call is valid for the proxy object
|
112
|
-
valid_call = (@
|
112
|
+
valid_call = (@obj.respond_to?(m) and @obj.method(m).arity == arity)
|
113
113
|
|
114
114
|
send(c, valid_call)
|
115
115
|
|
116
116
|
# Make the call if valid and send the result back
|
117
117
|
if valid_call then
|
118
118
|
args = recv(c)
|
119
|
-
send(c, @
|
119
|
+
send(c, @obj.send(m, *args) )
|
120
120
|
end
|
121
121
|
|
122
122
|
c.close
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplerpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Wattam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A very simple and fast RPC library
|
14
14
|
email: stephenwattam@gmail.com
|
@@ -17,9 +17,9 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/simplerpc/client.rb
|
20
|
-
- lib/simplerpc/server.rb
|
21
20
|
- lib/simplerpc/socket_protocol.rb
|
22
21
|
- lib/simplerpc/serialiser.rb
|
22
|
+
- lib/simplerpc/server.rb
|
23
23
|
- LICENSE
|
24
24
|
homepage: http://stephenwattam.com/projects/simplerpc
|
25
25
|
licenses:
|