protolink 0.2.10 → 0.2.11
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.
- data/lib/protolink/proto_socket.rb +14 -0
- data/lib/protolink/version.rb +1 -1
- metadata +5 -7
@@ -13,9 +13,14 @@ class ProtoSocket < FlashConnection
|
|
13
13
|
:payload => {:type => 'web', :user_id => @connection.current_user.id, :token => token}
|
14
14
|
|
15
15
|
periodic_ping
|
16
|
+
disconnect_if_no_ping_received
|
16
17
|
end
|
17
18
|
|
18
19
|
def receive_json(json)
|
20
|
+
if json["trigger"] == "socket.ping_received"
|
21
|
+
@last_ping_received = Time.now
|
22
|
+
return
|
23
|
+
end
|
19
24
|
@message_callback.call(json)
|
20
25
|
end
|
21
26
|
|
@@ -25,10 +30,19 @@ class ProtoSocket < FlashConnection
|
|
25
30
|
send_json :operation => 'ping'
|
26
31
|
end
|
27
32
|
end
|
33
|
+
|
34
|
+
def disconnect_if_no_ping_received
|
35
|
+
@ping_check ||= EventMachine.add_periodic_timer 30 do
|
36
|
+
if @last_ping_received && @last_ping_received < (Time.now - 60)
|
37
|
+
close_connection
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
28
41
|
|
29
42
|
def unbind
|
30
43
|
puts "DISCONNECTED"
|
31
44
|
EventMachine::cancel_timer @ping
|
45
|
+
EventMachine::cancel_timer @ping_check
|
32
46
|
EventMachine::add_timer(30) {
|
33
47
|
EventMachine.connect URI.parse(@connection.class.base_uri).host, 5000, ProtoSocket, @connection, @message_callback
|
34
48
|
}
|
data/lib/protolink/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protolink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 11
|
10
|
+
version: 0.2.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ali Jelveh
|
@@ -16,8 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
20
|
-
default_executable:
|
19
|
+
date: 2012-04-23 00:00:00 Z
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: eventmachine
|
@@ -76,7 +75,6 @@ files:
|
|
76
75
|
- lib/protolink/version.rb
|
77
76
|
- protolink.gemspec
|
78
77
|
- test/all_tests.rb
|
79
|
-
has_rdoc: true
|
80
78
|
homepage: http://github.com/protonet/protolink
|
81
79
|
licenses: []
|
82
80
|
|
@@ -106,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
104
|
requirements: []
|
107
105
|
|
108
106
|
rubyforge_project: protolink
|
109
|
-
rubygems_version: 1.
|
107
|
+
rubygems_version: 1.8.15
|
110
108
|
signing_key:
|
111
109
|
specification_version: 3
|
112
110
|
summary: Ruby wrapper for the ProtoNet API
|