phprpc 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/client.rb +2 -0
- data/examples/server.rb +9 -1
- data/lib/phprpc/base_server.rb +5 -5
- metadata +2 -2
data/examples/client.rb
CHANGED
data/examples/server.rb
CHANGED
@@ -12,6 +12,14 @@ def hello(s)
|
|
12
12
|
"hello: " << s
|
13
13
|
end
|
14
14
|
|
15
|
+
def use_session(a, session)
|
16
|
+
if session["a"] then
|
17
|
+
session["a"] += a
|
18
|
+
else
|
19
|
+
session["a"] = a
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
15
23
|
server = PHPRPC::Server.new
|
16
|
-
server.add(["add", "sub", "hello"])
|
24
|
+
server.add(["add", "sub", "hello", "use_session"])
|
17
25
|
server.start
|
data/lib/phprpc/base_server.rb
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
#
|
26
26
|
# Copyright (C) 2005-2008 Ma Bingyao <andot@ujn.edu.cn>
|
27
27
|
# Version: 3.0
|
28
|
-
# LastModified:
|
28
|
+
# LastModified: Dec 14, 2008
|
29
29
|
# This library is free. You can redistribute it and/or modify it.
|
30
30
|
|
31
31
|
require "digest/md5"
|
@@ -71,7 +71,7 @@ module PHPRPC
|
|
71
71
|
if block_given? then
|
72
72
|
@methods[aliasname[index].downcase] = block
|
73
73
|
elsif obj.respond_to?(name, true) then
|
74
|
-
@methods[aliasname[index].downcase] =
|
74
|
+
@methods[aliasname[index].downcase] = obj.method(name.to_sym)
|
75
75
|
end
|
76
76
|
}
|
77
77
|
end
|
@@ -103,7 +103,7 @@ module PHPRPC
|
|
103
103
|
end
|
104
104
|
ref = get_boolean('phprpc_ref', params)
|
105
105
|
args = get_args(params, key, encrypt)
|
106
|
-
result = encode_string(encrypt_string(PHP::Formator.serialize(invoke(func, args)), key, 2, encrypt), encode)
|
106
|
+
result = encode_string(encrypt_string(PHP::Formator.serialize(invoke(func, args, session)), key, 2, encrypt), encode)
|
107
107
|
body << 'phprpc_result="' << result << '";' << EOL
|
108
108
|
if ref then
|
109
109
|
args = encode_string(encrypt_string(PHP::Formator.serialize(args), key, 1, encrypt), encode)
|
@@ -136,10 +136,10 @@ module PHPRPC
|
|
136
136
|
|
137
137
|
private
|
138
138
|
|
139
|
-
def invoke(methodname, args)
|
139
|
+
def invoke(methodname, args, session)
|
140
140
|
if @methods.key?(methodname) then
|
141
141
|
m = @methods[methodname]
|
142
|
-
m.
|
142
|
+
m.call(*(((m.arity > 0) and (args.length + 1 == m.arity))? args + [session] : args))
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phprpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MA Bingyao ( andot )
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-12-14 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|