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 CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.1.3 2013-2-19
2
+
3
+ * bugfix queing on CometIO.push
4
+
1
5
  === 0.1.2 2013-2-17
2
6
 
3
7
  * emit event when client disconnect
@@ -41,7 +41,7 @@ module Sinatra
41
41
  s.close
42
42
  end
43
43
  end
44
-
44
+
45
45
  EM::add_timer 10 do
46
46
  begin
47
47
  s.write({:type => :__heartbeat, :data => {:time => Time.now.to_i}}.to_json)
@@ -33,22 +33,20 @@ class CometIO
33
33
  end
34
34
 
35
35
  def self.push(type, data, opt={})
36
- if opt[:to]
37
- self.sessions[opt[:to].to_s][:queue].push :type => type, :data => data
38
- else
39
- self.sessions.each do |id,s|
40
- if s[:queue].empty? and s[:stream] != nil
41
- begin
42
- s[:stream].write({:type => type, :data => data}.to_json)
43
- s[:stream].flush
44
- s[:stream].close
45
- rescue
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
@@ -1,3 +1,3 @@
1
1
  module SinatraCometIO
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  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.2
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-17 00:00:00.000000000 Z
12
+ date: 2013-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack