sinatra-cometio 0.1.8 → 0.1.9

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.9 2013-3-7
2
+
3
+ * use stream on post
4
+
1
5
  === 0.1.8 2013-3-6
2
6
 
3
7
  * update event_emitter.js
@@ -64,8 +64,18 @@ module Sinatra::CometIO
64
64
  type = params[:type]
65
65
  data = params[:data]
66
66
  from = params[:session]
67
- CometIO.emit type, data, from if type.to_s.size > 0
68
- {:session => from, :type => type, :data => data}.to_json
67
+ EM::defer do
68
+ CometIO.emit type, data, from unless type.to_s.empty?
69
+ end
70
+ stream :keep_open do |s|
71
+ begin
72
+ s.write({:session => from, :type => type, :data => data}.to_json)
73
+ s.flush
74
+ s.close
75
+ rescue
76
+ s.close
77
+ end
78
+ end
69
79
  end
70
80
 
71
81
  end
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module CometIO
3
- VERSION = '0.1.8'
3
+ VERSION = '0.1.9'
4
4
  end
5
5
  end
data/sample/Gemfile CHANGED
@@ -3,6 +3,7 @@ source :rubygems
3
3
  gem 'foreman'
4
4
  gem 'rack'
5
5
  gem 'sinatra'
6
+ gem 'backports', '< 3.1.0'
6
7
  gem 'thin'
7
8
  gem 'sinatra-contrib'
8
9
  gem 'event_emitter'
data/sample/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- backports (3.1.0)
4
+ backports (3.0.3)
5
5
  daemons (1.1.9)
6
6
  event_emitter (0.2.3)
7
7
  eventmachine (1.0.1)
@@ -43,6 +43,7 @@ PLATFORMS
43
43
  ruby
44
44
 
45
45
  DEPENDENCIES
46
+ backports (< 3.1.0)
46
47
  event_emitter
47
48
  foreman
48
49
  haml
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.8
4
+ version: 0.1.9
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-06 00:00:00.000000000 Z
12
+ date: 2013-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack