sinatra-cometio 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/sinatra/application.rb +1 -1
- data/lib/sinatra/cometio.rb +12 -14
- data/lib/sinatra-cometio/version.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/lib/sinatra/application.rb
CHANGED
data/lib/sinatra/cometio.rb
CHANGED
@@ -33,22 +33,20 @@ class CometIO
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.push(type, data, opt={})
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
s[:stream].class
|
47
|
-
s[:queue].push :type => type, :data => data
|
48
|
-
end
|
49
|
-
else
|
36
|
+
session_ids = opt[:to].to_s.empty? ? self.sessions.keys : [opt[:to]]
|
37
|
+
session_ids.each do |id|
|
38
|
+
s = self.sessions[id]
|
39
|
+
if s[:queue].empty? and s[:stream] != nil
|
40
|
+
begin
|
41
|
+
s[:stream].write({:type => type, :data => data}.to_json)
|
42
|
+
s[:stream].flush
|
43
|
+
s[:stream].close
|
44
|
+
rescue
|
45
|
+
s[:stream].close
|
50
46
|
s[:queue].push :type => type, :data => data
|
51
47
|
end
|
48
|
+
else
|
49
|
+
s[:queue].push :type => type, :data => data
|
52
50
|
end
|
53
51
|
end
|
54
52
|
end
|
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.3
|
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-02-
|
12
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|