amf_socket 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/amf_socket/amf_rpc_connection.rb +11 -1
- data/lib/amf_socket/version.rb +1 -1
- data/spec/amf_socket/amf_rpc_connection_spec.rb +27 -0
- 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: c35655722b57918c2d2c95679c7f1a917daa39fa
|
4
|
+
data.tar.gz: 83060f2c71b94524a7a8e3ab0bbda8a33517348d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13727696af4c8e150ca9ae90cfab18f5b7a6bc15016b881c4edd5872f130d0072859dbb8deeaf9334aafb026b6951a16dc1242698b6d49a7fdc7d125272d7fbe
|
7
|
+
data.tar.gz: 8b130be6b441e61d1a51560830c70a6fefc9bd02e2f65da0eae2bd869b079999385c79f84183c057f1f5b97f4247aae97afb13d2c26e126c0180d03ab693411b
|
data/Gemfile.lock
CHANGED
@@ -37,7 +37,12 @@ class AmfSocket::AmfRpcConnection < AmfSocket::AmfConnection
|
|
37
37
|
case object[:type]
|
38
38
|
when 'rpcRequest'
|
39
39
|
request = AmfSocket::RpcReceivedRequest.new(object, self)
|
40
|
-
|
40
|
+
case request.command
|
41
|
+
when 'amf_socket_ping'
|
42
|
+
receive_ping_request(request)
|
43
|
+
else
|
44
|
+
receive_request(request)
|
45
|
+
end
|
41
46
|
when 'rpcResponse'
|
42
47
|
receive_response(object)
|
43
48
|
when 'rpcMessage'
|
@@ -72,6 +77,11 @@ class AmfSocket::AmfRpcConnection < AmfSocket::AmfConnection
|
|
72
77
|
request.reply("You should override #{self.class.to_s}#receive_request.")
|
73
78
|
end
|
74
79
|
|
80
|
+
# Respond to server ping requests (when used with EM.connect for client side sockets).
|
81
|
+
def receive_ping_request(request)
|
82
|
+
request.reply(nil)
|
83
|
+
end
|
84
|
+
|
75
85
|
# Override this method in your subclass.
|
76
86
|
def receive_message(message)
|
77
87
|
end
|
data/lib/amf_socket/version.rb
CHANGED
@@ -28,6 +28,11 @@ class AmfRpcConnTestable < AmfSocket::AmfRpcConnection
|
|
28
28
|
@received_requests << request
|
29
29
|
end
|
30
30
|
|
31
|
+
def receive_ping_request(request)
|
32
|
+
$receive_ping_callback.call(request)
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
31
36
|
def receive_message(message)
|
32
37
|
@received_messages << message
|
33
38
|
end
|
@@ -113,6 +118,28 @@ describe AmfSocket::AmfRpcConnection do
|
|
113
118
|
request.connection.should == @conn
|
114
119
|
end
|
115
120
|
|
121
|
+
it 'should handle received ping requests and reply' do
|
122
|
+
object = {
|
123
|
+
:type => 'rpcRequest',
|
124
|
+
:request => {
|
125
|
+
:messageId => '123',
|
126
|
+
:command => 'amf_socket_ping',
|
127
|
+
:params => {
|
128
|
+
:time => Time.now,
|
129
|
+
:latency => 0.5
|
130
|
+
}
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
$receive_ping_callback = proc { |request|
|
135
|
+
request.should_receive(:reply)
|
136
|
+
}
|
137
|
+
|
138
|
+
@conn.receive_object(object)
|
139
|
+
|
140
|
+
request = @conn.received_requests.first
|
141
|
+
end
|
142
|
+
|
116
143
|
it 'should handle recevied messages' do
|
117
144
|
object = {
|
118
145
|
:type => 'rpcMessage',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amf_socket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Remesch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|