revent 0.4.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/example/as_r/Document.as +1 -0
- data/example/as_r/README +3 -0
- data/{test → example}/as_r/client.fla +0 -0
- data/example/as_r/client.swf +0 -0
- data/{test → example}/as_r/server.rb +7 -14
- data/example/r_r/client.rb +46 -0
- data/example/r_r/server.rb +46 -0
- data/lib/revent/Client.as +14 -14
- data/lib/revent/{CallEvent.as → InvokeEvent.as} +4 -4
- data/lib/revent/as_r.rb +16 -11
- data/lib/revent/captcha.rb +1 -1
- data/lib/revent/r_r.rb +13 -13
- metadata +50 -30
- data/test/as_r/Document.as +0 -81
- data/test/as_r/client.swf +0 -0
- data/test/r_r/client.rb +0 -34
- data/test/r_r/server.rb +0 -33
@@ -0,0 +1 @@
|
|
1
|
+
package {
|
data/example/as_r/README
ADDED
File without changes
|
Binary file
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
require 'revent/as_r'
|
2
3
|
|
3
4
|
HOST = 'localhost'
|
@@ -13,34 +14,26 @@ class Server
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def on_connect(client)
|
16
|
-
puts "on_connect:"
|
17
|
-
puts client.remote_ip
|
17
|
+
puts "on_connect: ", client.remote_ip
|
18
18
|
end
|
19
19
|
|
20
20
|
def on_close(client)
|
21
|
-
puts "on_close:"
|
22
|
-
puts client.remote_ip
|
21
|
+
puts "on_close:", client.remote_ip
|
23
22
|
end
|
24
23
|
|
25
|
-
def
|
26
|
-
puts "
|
24
|
+
def on_invoke(client, cmd, value)
|
25
|
+
puts "on_invoke: ", cmd, value
|
27
26
|
if cmd == CMD_TEST_BYTE_ARRAY
|
28
27
|
test_byte_array(client, value)
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
32
31
|
def on_result(client, cmd, value)
|
33
|
-
puts "on_result:"
|
34
|
-
puts client.remote_ip
|
35
|
-
puts cmd
|
36
|
-
puts result
|
32
|
+
puts "on_result: ", client.remote_ip, cmd, result
|
37
33
|
end
|
38
34
|
|
39
35
|
def on_error(client, cmd, value)
|
40
|
-
puts "on_error:"
|
41
|
-
puts client.remote_ip
|
42
|
-
puts cmd
|
43
|
-
puts error
|
36
|
+
puts "on_error: ", client.remote_ip, cmd, error
|
44
37
|
end
|
45
38
|
|
46
39
|
# ----------------------------------------------------------------------------
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'revent/r_r'
|
3
|
+
|
4
|
+
class Client
|
5
|
+
include Revent::RRClient
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@data_prefix = ''
|
9
|
+
50.times { |i| @data_prefix << i.to_s }
|
10
|
+
|
11
|
+
connect('localhost', 1943)
|
12
|
+
end
|
13
|
+
|
14
|
+
N = 10**4
|
15
|
+
|
16
|
+
def on_connect
|
17
|
+
@now = Time.now
|
18
|
+
@count = 0
|
19
|
+
N.times do |i|
|
20
|
+
invoke("#{@data_prefix}#{i}", i)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def on_invoke(cmd, value)
|
25
|
+
cmd =~ /#{@data_prefix}(.+)/
|
26
|
+
puts 'Error at on_invoke' if value != $1.to_i
|
27
|
+
value
|
28
|
+
end
|
29
|
+
|
30
|
+
def on_result(cmd, value)
|
31
|
+
cmd =~ /#{@data_prefix}(.+)/
|
32
|
+
puts 'Error at on_result' if value != $1.to_i
|
33
|
+
|
34
|
+
@count += 1
|
35
|
+
if @count == N
|
36
|
+
dt = Time.now - @now
|
37
|
+
puts N
|
38
|
+
puts dt
|
39
|
+
puts N/dt
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
EventMachine::run do
|
45
|
+
Client.new
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'revent/r_r'
|
3
|
+
|
4
|
+
class Server
|
5
|
+
include Revent::RRServer
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@data_prefix = ''
|
9
|
+
50.times { |i| @data_prefix << i.to_s }
|
10
|
+
|
11
|
+
start_server('localhost', 1943)
|
12
|
+
end
|
13
|
+
|
14
|
+
N = 10**4
|
15
|
+
|
16
|
+
def on_connect(con)
|
17
|
+
@count = 0
|
18
|
+
@now = Time.now
|
19
|
+
N.times do |i|
|
20
|
+
con.invoke("#{@data_prefix}#{i}", i)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def on_invoke(con, cmd, value)
|
25
|
+
cmd =~ /#{@data_prefix}(.+)/
|
26
|
+
puts 'Error at on_invoke' if value != $1.to_i
|
27
|
+
value
|
28
|
+
end
|
29
|
+
|
30
|
+
def on_result(con, cmd, value)
|
31
|
+
cmd =~ /#{@data_prefix}(.+)/
|
32
|
+
puts 'Error at on_result' if value != $1.to_i
|
33
|
+
|
34
|
+
@count += 1
|
35
|
+
if @count == N
|
36
|
+
dt = Time.now - @now
|
37
|
+
puts N
|
38
|
+
puts dt
|
39
|
+
puts N/dt
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
EventMachine::run do
|
45
|
+
Server.new
|
46
|
+
end
|
data/lib/revent/Client.as
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
import flash.utils.ByteArray;
|
6
6
|
|
7
7
|
public class Client extends EventDispatcher {
|
8
|
-
private static const
|
8
|
+
private static const TYPE_INVOKE:int = 0;
|
9
9
|
private static const TYPE_RESULT:int = 1;
|
10
10
|
private static const TYPE_ERROR:int = 2;
|
11
11
|
|
@@ -15,7 +15,7 @@
|
|
15
15
|
public function Client():void {
|
16
16
|
_socket = new Socket();
|
17
17
|
_socket.objectEncoding = ObjectEncoding.AMF3;
|
18
|
-
|
18
|
+
|
19
19
|
_socket.addEventListener(Event.CONNECT, onConnect);
|
20
20
|
_socket.addEventListener(Event.CLOSE, onClose);
|
21
21
|
_socket.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
|
@@ -37,8 +37,8 @@
|
|
37
37
|
return _socket.connected;
|
38
38
|
}
|
39
39
|
|
40
|
-
public function
|
41
|
-
_socket.writeObject([
|
40
|
+
public function invoke(cmd:Object, value:Object):void {
|
41
|
+
_socket.writeObject([TYPE_INVOKE, cmd, value]);
|
42
42
|
_socket.flush();
|
43
43
|
}
|
44
44
|
|
@@ -55,19 +55,19 @@
|
|
55
55
|
// ---------------------------------------------------------------------------
|
56
56
|
|
57
57
|
private function onConnect(event:Event):void {
|
58
|
-
dispatchEvent(new
|
58
|
+
dispatchEvent(new InvokeEvent(InvokeEvent.CONNECT, null, null));
|
59
59
|
}
|
60
60
|
|
61
61
|
private function onClose(event:Event):void {
|
62
|
-
dispatchEvent(new
|
62
|
+
dispatchEvent(new InvokeEvent(InvokeEvent.CLOSE, null, null));
|
63
63
|
}
|
64
64
|
|
65
65
|
private function onIOError(event:IOErrorEvent):void {
|
66
|
-
dispatchEvent(new
|
66
|
+
dispatchEvent(new InvokeEvent(InvokeEvent.IO_ERROR, null, null));
|
67
67
|
}
|
68
68
|
|
69
69
|
private function onSecurityError(event:SecurityErrorEvent):void {
|
70
|
-
dispatchEvent(new
|
70
|
+
dispatchEvent(new InvokeEvent(InvokeEvent.SECURITY_ERROR, null, null));
|
71
71
|
}
|
72
72
|
|
73
73
|
private function onData(event:ProgressEvent):void {
|
@@ -86,16 +86,16 @@
|
|
86
86
|
var cmd:Object = o[1];
|
87
87
|
var value:Object = o[2];
|
88
88
|
|
89
|
-
var e:
|
89
|
+
var e:InvokeEvent;
|
90
90
|
switch (type) {
|
91
|
-
case
|
92
|
-
e = new
|
91
|
+
case TYPE_INVOKE:
|
92
|
+
e = new InvokeEvent(InvokeEvent.INVOKE, cmd, value);
|
93
93
|
break;
|
94
94
|
case TYPE_RESULT:
|
95
|
-
e = new
|
95
|
+
e = new InvokeEvent(InvokeEvent.RESULT, cmd, value);
|
96
96
|
break;
|
97
97
|
case TYPE_ERROR:
|
98
|
-
e = new
|
98
|
+
e = new InvokeEvent(InvokeEvent.ERROR, cmd, value);
|
99
99
|
break;
|
100
100
|
}
|
101
101
|
dispatchEvent(e);
|
@@ -110,4 +110,4 @@
|
|
110
110
|
}
|
111
111
|
}
|
112
112
|
}
|
113
|
-
}
|
113
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
package revent {
|
2
2
|
import flash.events.Event;
|
3
3
|
|
4
|
-
public class
|
4
|
+
public class InvokeEvent extends Event {
|
5
5
|
// The connection has opened, communication is ready.
|
6
6
|
public static const CONNECT:String = "CONNECT";
|
7
7
|
// The connection has closed, do not do any communication.
|
@@ -9,17 +9,17 @@
|
|
9
9
|
public static const IO_ERROR:String = "IO_ERROR";
|
10
10
|
public static const SECURITY_ERROR:String = "SECURITY_ERROR";
|
11
11
|
|
12
|
-
public static const
|
12
|
+
public static const INVOKE:String = "INVOKE";
|
13
13
|
public static const RESULT:String = "RESULT";
|
14
14
|
public static const ERROR:String = "ERROR";
|
15
15
|
|
16
16
|
public var cmd:Object;
|
17
17
|
public var value:Object;
|
18
18
|
|
19
|
-
public function
|
19
|
+
public function InvokeEvent(type:String, cmd:Object, value:Object):void {
|
20
20
|
this.cmd = cmd;
|
21
21
|
this.value = value;
|
22
22
|
super(type);
|
23
23
|
}
|
24
24
|
}
|
25
|
-
}
|
25
|
+
}
|
data/lib/revent/as_r.rb
CHANGED
@@ -13,13 +13,13 @@ module Revent
|
|
13
13
|
# Called by Flash player
|
14
14
|
CMD_POLICY = '<policy-file-request/>' + "\0"
|
15
15
|
|
16
|
-
|
16
|
+
TYPE_INVOKE = 0
|
17
17
|
TYPE_RESULT = 1
|
18
18
|
TYPE_ERROR = 2
|
19
19
|
|
20
|
-
attr_writer
|
20
|
+
attr_writer :me
|
21
21
|
attr_accessor :session # Something that you want to associate with this connection
|
22
|
-
attr_writer
|
22
|
+
attr_writer :cons
|
23
23
|
|
24
24
|
def post_init
|
25
25
|
@connected = true
|
@@ -55,6 +55,7 @@ module Revent
|
|
55
55
|
end
|
56
56
|
rescue
|
57
57
|
@me.logger.error($!)
|
58
|
+
@me.logger.error($!.backtrace.join("\n"))
|
58
59
|
close_connection
|
59
60
|
end
|
60
61
|
|
@@ -64,8 +65,8 @@ module Revent
|
|
64
65
|
value = o[2]
|
65
66
|
|
66
67
|
case type
|
67
|
-
when
|
68
|
-
@me.
|
68
|
+
when TYPE_INVOKE
|
69
|
+
@me.on_invoke(self, cmd, value)
|
69
70
|
when TYPE_RESULT
|
70
71
|
@me.on_result(self, cmd, value)
|
71
72
|
when TYPE_ERROR
|
@@ -73,6 +74,7 @@ module Revent
|
|
73
74
|
end
|
74
75
|
rescue
|
75
76
|
@me.logger.error($!)
|
77
|
+
@me.logger.error($!.backtrace.join("\n"))
|
76
78
|
close_connection
|
77
79
|
end
|
78
80
|
|
@@ -100,16 +102,17 @@ module Revent
|
|
100
102
|
peername = get_peername
|
101
103
|
return @last_ip if peername.nil?
|
102
104
|
|
103
|
-
a = get_peername[2,6].unpack("nC4")
|
105
|
+
a = get_peername[2, 6].unpack("nC4")
|
104
106
|
a.delete_at(0)
|
105
107
|
@last_ip = a.join('.')
|
106
108
|
end
|
107
109
|
|
108
|
-
def
|
109
|
-
send_amf3_data([
|
110
|
+
def invoke(cmd, value, close_connection_after_writing = false)
|
111
|
+
send_amf3_data([TYPE_INVOKE, cmd, value])
|
110
112
|
self.close_connection_after_writing if close_connection_after_writing
|
111
113
|
rescue
|
112
114
|
@me.logger.error($!)
|
115
|
+
@me.logger.error($!.backtrace.join("\n"))
|
113
116
|
end
|
114
117
|
|
115
118
|
def result(cmd, value, close_connection_after_writing = false)
|
@@ -117,6 +120,7 @@ module Revent
|
|
117
120
|
self.close_connection_after_writing if close_connection_after_writing
|
118
121
|
rescue
|
119
122
|
@me.logger.error($!)
|
123
|
+
@me.logger.error($!.backtrace.join("\n"))
|
120
124
|
end
|
121
125
|
|
122
126
|
def error(cmd, value, close_connection_after_writing = false)
|
@@ -124,6 +128,7 @@ module Revent
|
|
124
128
|
self.close_connection_after_writing if close_connection_after_writing
|
125
129
|
rescue
|
126
130
|
@me.logger.error($!)
|
131
|
+
@me.logger.error($!.backtrace.join("\n"))
|
127
132
|
end
|
128
133
|
|
129
134
|
def compress(value)
|
@@ -149,11 +154,11 @@ module Revent
|
|
149
154
|
@logger = Logger.new(STDOUT) if @logger.nil?
|
150
155
|
@max_cmd_length = DEFAULT_MAX_CMD_LENGTH if @max_cmd_length.nil?
|
151
156
|
if @policy.nil?
|
152
|
-
@policy =
|
157
|
+
@policy = %Q{
|
153
158
|
<cross-domain-policy>
|
154
159
|
<allow-access-from domain="*" to-ports="#{port}" />
|
155
160
|
</cross-domain-policy>
|
156
|
-
|
161
|
+
}
|
157
162
|
end
|
158
163
|
|
159
164
|
@revent_cons = []
|
@@ -182,7 +187,7 @@ EOF
|
|
182
187
|
def on_close(client)
|
183
188
|
end
|
184
189
|
|
185
|
-
def
|
190
|
+
def on_invoke(client, cmd, value)
|
186
191
|
end
|
187
192
|
|
188
193
|
def on_result(client, cmd, value)
|
data/lib/revent/captcha.rb
CHANGED
data/lib/revent/r_r.rb
CHANGED
@@ -7,13 +7,13 @@ require "#{File.dirname(__FILE__)}/synchronize"
|
|
7
7
|
module Revent
|
8
8
|
# Included by both Revent::RRServer and Revent::RRClient.
|
9
9
|
module RRCon
|
10
|
-
|
10
|
+
TYPE_INVOKE = 0
|
11
11
|
TYPE_RESULT = 1
|
12
12
|
TYPE_ERROR = 2
|
13
13
|
|
14
|
-
attr_writer
|
14
|
+
attr_writer :me
|
15
15
|
attr_accessor :session # Something that you want to associate with this connection
|
16
|
-
attr_writer
|
16
|
+
attr_writer :cons # Only used for Revent::RRServer
|
17
17
|
|
18
18
|
def post_init
|
19
19
|
@connected = true
|
@@ -37,8 +37,8 @@ module Revent
|
|
37
37
|
value = o[2]
|
38
38
|
|
39
39
|
case type
|
40
|
-
when
|
41
|
-
value = @cons.nil? ? @me.
|
40
|
+
when TYPE_INVOKE
|
41
|
+
value = @cons.nil? ? @me.on_invoke(cmd, value) : @me.on_invoke(self, cmd, value)
|
42
42
|
o = [TYPE_RESULT, cmd, value]
|
43
43
|
send_data(Marshal.dump(o))
|
44
44
|
when TYPE_RESULT
|
@@ -61,7 +61,7 @@ module Revent
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
|
64
|
+
# --------------------------------------------------------------------------
|
65
65
|
|
66
66
|
def connected?
|
67
67
|
@connected
|
@@ -72,13 +72,13 @@ module Revent
|
|
72
72
|
peername = get_peername
|
73
73
|
return @last_ip if peername.nil?
|
74
74
|
|
75
|
-
a = get_peername[2,6].unpack("nC4")
|
75
|
+
a = get_peername[2, 6].unpack("nC4")
|
76
76
|
a.delete_at(0)
|
77
77
|
@last_ip = a.join('.')
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
81
|
-
o = [
|
80
|
+
def invoke(cmd, value)
|
81
|
+
o = [TYPE_INVOKE, cmd, value]
|
82
82
|
send_data(Marshal.dump(o))
|
83
83
|
end
|
84
84
|
end
|
@@ -112,7 +112,7 @@ module Revent
|
|
112
112
|
def on_close(client)
|
113
113
|
end
|
114
114
|
|
115
|
-
def
|
115
|
+
def on_invoke(client, cmd, value)
|
116
116
|
end
|
117
117
|
|
118
118
|
def on_result(client, cmd, value)
|
@@ -150,8 +150,8 @@ module Revent
|
|
150
150
|
@revent_con.remote_ip if connected?
|
151
151
|
end
|
152
152
|
|
153
|
-
def
|
154
|
-
@revent_con.
|
153
|
+
def invoke(cmd, value)
|
154
|
+
@revent_con.invoke(cmd, value) if connected?
|
155
155
|
end
|
156
156
|
|
157
157
|
def close_connection
|
@@ -170,7 +170,7 @@ module Revent
|
|
170
170
|
def on_close
|
171
171
|
end
|
172
172
|
|
173
|
-
def
|
173
|
+
def on_invoke(cmd, value)
|
174
174
|
end
|
175
175
|
|
176
176
|
def on_result(cmd, value)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.5"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ngoc DAO Thanh
|
@@ -9,10 +9,29 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-09-24 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: eventmachine
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: crypt
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
16
35
|
description:
|
17
36
|
email: ngocdaothanh@gmail.com
|
18
37
|
executables: []
|
@@ -22,43 +41,44 @@ extensions: []
|
|
22
41
|
extra_rdoc_files: []
|
23
42
|
|
24
43
|
files:
|
25
|
-
-
|
26
|
-
-
|
27
|
-
-
|
28
|
-
-
|
29
|
-
-
|
30
|
-
-
|
31
|
-
-
|
32
|
-
-
|
33
|
-
-
|
44
|
+
- example
|
45
|
+
- example/as_r
|
46
|
+
- example/as_r/client.fla
|
47
|
+
- example/as_r/client.swf
|
48
|
+
- example/as_r/Document.as
|
49
|
+
- example/as_r/README
|
50
|
+
- example/as_r/server.rb
|
51
|
+
- example/r_r
|
52
|
+
- example/r_r/client.rb
|
53
|
+
- example/r_r/server.rb
|
54
|
+
- INSTALL
|
34
55
|
- lib
|
35
56
|
- lib/revent
|
36
|
-
- lib/revent/r_r.rb
|
37
|
-
- lib/revent/as_r.rb
|
38
|
-
- lib/revent/Client.as
|
39
|
-
- lib/revent/synchronize.rb
|
40
|
-
- lib/revent/captcha.rb
|
41
57
|
- lib/revent/amf3
|
58
|
+
- lib/revent/amf3/amf3.rb
|
42
59
|
- lib/revent/amf3/app
|
43
|
-
- lib/revent/amf3/app/fault_object.rb
|
44
60
|
- lib/revent/amf3/app/configuration.rb
|
45
|
-
- lib/revent/amf3/
|
61
|
+
- lib/revent/amf3/app/fault_object.rb
|
62
|
+
- lib/revent/amf3/exception
|
63
|
+
- lib/revent/amf3/exception/rubyamf_exception.rb
|
46
64
|
- lib/revent/amf3/io
|
47
65
|
- lib/revent/amf3/io/amf_deserializer.rb
|
48
|
-
- lib/revent/amf3/io/read_write.rb
|
49
66
|
- lib/revent/amf3/io/amf_serializer.rb
|
50
67
|
- lib/revent/amf3/io/byte_array.rb
|
68
|
+
- lib/revent/amf3/io/read_write.rb
|
69
|
+
- lib/revent/amf3/LICENSE
|
70
|
+
- lib/revent/amf3/README
|
51
71
|
- lib/revent/amf3/util
|
52
|
-
- lib/revent/amf3/util/vo_helper.rb
|
53
72
|
- lib/revent/amf3/util/string.rb
|
54
|
-
- lib/revent/amf3/
|
55
|
-
- lib/revent/
|
56
|
-
- lib/revent/
|
57
|
-
- lib/revent/
|
58
|
-
- lib/revent/
|
59
|
-
-
|
60
|
-
-
|
73
|
+
- lib/revent/amf3/util/vo_helper.rb
|
74
|
+
- lib/revent/as_r.rb
|
75
|
+
- lib/revent/captcha.rb
|
76
|
+
- lib/revent/Client.as
|
77
|
+
- lib/revent/InvokeEvent.as
|
78
|
+
- lib/revent/r_r.rb
|
79
|
+
- lib/revent/synchronize.rb
|
61
80
|
- README
|
81
|
+
- setup.rb
|
62
82
|
has_rdoc: false
|
63
83
|
homepage: http://revent.rubyforge.org
|
64
84
|
post_install_message:
|
@@ -81,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
101
|
requirements: []
|
82
102
|
|
83
103
|
rubyforge_project: revent
|
84
|
-
rubygems_version: 1.0
|
104
|
+
rubygems_version: 1.2.0
|
85
105
|
signing_key:
|
86
106
|
specification_version: 2
|
87
107
|
summary: RPC based on EventMachine
|
data/test/as_r/Document.as
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
package {
|
2
|
-
import flash.display.Sprite;
|
3
|
-
import flash.events.MouseEvent;
|
4
|
-
import flash.utils.ByteArray;
|
5
|
-
|
6
|
-
import revent.Client;
|
7
|
-
import revent.CallEvent;
|
8
|
-
|
9
|
-
public class Document extends Sprite {
|
10
|
-
private static const HOST:String = "localhost";
|
11
|
-
private static const PORT:int = 1935;
|
12
|
-
|
13
|
-
private static const CMD_TEST_BYTE_ARRAY:int = 0;
|
14
|
-
|
15
|
-
private var _client:Client;
|
16
|
-
private var _size:int;
|
17
|
-
|
18
|
-
public function Document():void {
|
19
|
-
_byteArrayBtn.addEventListener(MouseEvent.CLICK, onByteArrayBtnClick);
|
20
|
-
|
21
|
-
_client = new Client();
|
22
|
-
_client.addEventListener(CallEvent.CONNECT, onConnect);
|
23
|
-
_client.addEventListener(CallEvent.CLOSE, onClose);
|
24
|
-
_client.addEventListener(CallEvent.IO_ERROR, onIOError);
|
25
|
-
_client.addEventListener(CallEvent.SECURITY_ERROR, onSecurityError);
|
26
|
-
_client.addEventListener(CallEvent.CALL, onCall);
|
27
|
-
_client.addEventListener(CallEvent.RESULT, onResult);
|
28
|
-
_client.addEventListener(CallEvent.ERROR, onError);
|
29
|
-
_client.connect(HOST, PORT);
|
30
|
-
}
|
31
|
-
|
32
|
-
// ---------------------------------------------------------------------------
|
33
|
-
|
34
|
-
private function onConnect(event:CallEvent):void {
|
35
|
-
_status.text += "onConnect\n";
|
36
|
-
}
|
37
|
-
|
38
|
-
private function onClose(event:CallEvent):void {
|
39
|
-
_status.text += "onClose\n";
|
40
|
-
}
|
41
|
-
|
42
|
-
private function onIOError(event:CallEvent):void {
|
43
|
-
_status.text += "onIOError\n";
|
44
|
-
}
|
45
|
-
|
46
|
-
private function onSecurityError(event:CallEvent):void {
|
47
|
-
_status.text += "onSecurityError\n";
|
48
|
-
}
|
49
|
-
|
50
|
-
private function onCall(event:CallEvent):void {
|
51
|
-
_status.text += "onCall\n";
|
52
|
-
_status.text += "cmd:" + event.cmd;
|
53
|
-
_status.text += "value:" + event.value;
|
54
|
-
}
|
55
|
-
|
56
|
-
private function onResult(event:CallEvent):void {
|
57
|
-
_status.text += "onResult";
|
58
|
-
_status.text += "cmd:" + event.cmd;
|
59
|
-
|
60
|
-
var b:ByteArray = event.value as ByteArray;
|
61
|
-
_status.text += "Received bytes: " + b.length;
|
62
|
-
_size += 1024;
|
63
|
-
_status.text += "Testing byte array with size: " + _size;
|
64
|
-
_client.call(CMD_TEST_BYTE_ARRAY, _size);
|
65
|
-
}
|
66
|
-
|
67
|
-
private function onError(event:CallEvent):void {
|
68
|
-
_status.text += "onError";
|
69
|
-
_status.text += "cmd: " + event.cmd;
|
70
|
-
_status.text += "value: " + event.value;
|
71
|
-
}
|
72
|
-
|
73
|
-
// ---------------------------------------------------------------------------
|
74
|
-
|
75
|
-
private function onByteArrayBtnClick(event:MouseEvent):void {
|
76
|
-
_size = 1024;
|
77
|
-
_status.text += "Testing byte array with size: " + _size;
|
78
|
-
_client.call(CMD_TEST_BYTE_ARRAY, _size);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}
|
data/test/as_r/client.swf
DELETED
Binary file
|
data/test/r_r/client.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'revent'
|
2
|
-
|
3
|
-
class Client
|
4
|
-
include ReventClient
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
connect('localhost', 1943)
|
8
|
-
end
|
9
|
-
|
10
|
-
N = 10**5
|
11
|
-
|
12
|
-
def on_connect
|
13
|
-
@now = Time.now
|
14
|
-
@x = 0
|
15
|
-
N.times do |i|
|
16
|
-
call('hello', i)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def on_result(cmd, arg)
|
21
|
-
@x += 1
|
22
|
-
#puts @x
|
23
|
-
if @x == N
|
24
|
-
dt = Time.now - @now
|
25
|
-
puts N
|
26
|
-
puts dt
|
27
|
-
puts N/dt
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
EventMachine::run do
|
33
|
-
Client.new
|
34
|
-
end
|
data/test/r_r/server.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'revent'
|
2
|
-
|
3
|
-
class Server
|
4
|
-
include ReventServer
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
start_server('localhost', 1943)
|
8
|
-
end
|
9
|
-
|
10
|
-
N = 10**5
|
11
|
-
|
12
|
-
def on_connect(con)
|
13
|
-
@x = 0
|
14
|
-
@now = Time.now
|
15
|
-
N.times do |i|
|
16
|
-
con.call('hello', i)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def on_result(con, cmd, arg)
|
21
|
-
@x += 1
|
22
|
-
if @x == N
|
23
|
-
dt = Time.now - @now
|
24
|
-
puts N
|
25
|
-
puts dt
|
26
|
-
puts N/dt
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
EventMachine::run do
|
32
|
-
Server.new
|
33
|
-
end
|