sinatra-cometio 0.1.6 → 0.1.7
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/History.txt +5 -0
- data/README.md +1 -1
- data/lib/js/cometio.js +1 -1
- data/lib/sinatra-cometio/application.rb +1 -1
- data/lib/sinatra-cometio/options.rb +1 -1
- data/lib/sinatra-cometio/version.rb +1 -1
- data/lib/sinatra/cometio.rb +2 -2
- data/lib/sinatra/cometio/client.rb +8 -6
- data/sample/config.ru +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/README.md
CHANGED
data/lib/js/cometio.js
CHANGED
data/lib/sinatra/cometio.rb
CHANGED
@@ -21,7 +21,7 @@ class CometIO
|
|
21
21
|
|
22
22
|
def self.gc
|
23
23
|
self.sessions.each do |id, s|
|
24
|
-
next unless s[:last] and s[:last] < Time.now-CometIO.options[:
|
24
|
+
next unless s[:last] and s[:last] < Time.now-CometIO.options[:timeout]*2-10
|
25
25
|
self.sessions.delete id rescue next
|
26
26
|
self.emit :disconnect, id
|
27
27
|
end
|
@@ -30,7 +30,7 @@ class CometIO
|
|
30
30
|
EM::defer do
|
31
31
|
loop do
|
32
32
|
self.gc
|
33
|
-
sleep CometIO.options[:
|
33
|
+
sleep CometIO.options[:timeout]+5
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -20,11 +20,10 @@ class CometIO
|
|
20
20
|
|
21
21
|
def push(type, data)
|
22
22
|
begin
|
23
|
-
res = HTTParty.post @url, :body => {:type => type, :data => data, :session => @session}
|
23
|
+
res = HTTParty.post @url, :timeout => 10, :body => {:type => type, :data => data, :session => @session}
|
24
|
+
emit :error, "CometIO push error" unless res.code == 200
|
24
25
|
rescue StandardError, Timeout::Error => e
|
25
26
|
emit :error, "CometIO push error"
|
26
|
-
ensure
|
27
|
-
emit :error, "CometIO push error" unless res.code == 200
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
@@ -49,7 +48,7 @@ class CometIO
|
|
49
48
|
Thread.new do
|
50
49
|
while @running do
|
51
50
|
begin
|
52
|
-
res = HTTParty.get "#{@url}?session=#{@session}", :timeout =>
|
51
|
+
res = HTTParty.get "#{@url}?session=#{@session}", :timeout => 120
|
53
52
|
unless res.code == 200
|
54
53
|
self.emit :error, "CometIO get error"
|
55
54
|
sleep 10
|
@@ -57,9 +56,12 @@ class CometIO
|
|
57
56
|
else
|
58
57
|
data = JSON.parse res.body
|
59
58
|
self.emit data['type'], data['data']
|
59
|
+
next
|
60
60
|
end
|
61
|
-
rescue
|
62
|
-
|
61
|
+
rescue Timeout::Error, JSON::ParserError
|
62
|
+
next
|
63
|
+
rescue StandardError
|
64
|
+
self.emit :error, "CometIO get error 2"
|
63
65
|
sleep 10
|
64
66
|
next
|
65
67
|
end
|
data/sample/config.ru
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-cometio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|