sinatra-cometio 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/js/cometio.js +4 -0
- data/lib/js/event_emitter.js +9 -6
- data/lib/sinatra-cometio/application.rb +2 -1
- data/lib/sinatra-cometio/version.rb +1 -1
- data/sample/Gemfile.lock +2 -2
- data/sinatra-cometio.gemspec +1 -1
- metadata +6 -6
data/History.txt
CHANGED
data/lib/js/cometio.js
CHANGED
data/lib/js/event_emitter.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// event_emitter.js v0.0.
|
1
|
+
// event_emitter.js v0.0.8
|
2
2
|
// https://github.com/shokai/event_emitter.js
|
3
3
|
// (c) 2013 Sho Hashimoto <hashimoto@shokai.org>
|
4
4
|
// The MIT License
|
@@ -38,13 +38,15 @@ var EventEmitter = function(){
|
|
38
38
|
switch(e.type){
|
39
39
|
case type:
|
40
40
|
e.listener(data);
|
41
|
+
if(e.once) e.type = null;
|
41
42
|
break
|
42
|
-
case
|
43
|
+
case "*":
|
43
44
|
e.listener(type, data);
|
45
|
+
if(e.once) e.type = null;
|
44
46
|
break
|
45
47
|
}
|
46
|
-
if(e.once) self.removeListener(e.id);
|
47
48
|
}
|
49
|
+
self.removeListener();
|
48
50
|
};
|
49
51
|
|
50
52
|
this.removeListener = function(id_or_type){
|
@@ -52,10 +54,11 @@ var EventEmitter = function(){
|
|
52
54
|
var e = self.__events[i];
|
53
55
|
switch(typeof id_or_type){
|
54
56
|
case "number":
|
55
|
-
if(e.id
|
57
|
+
if(e.id === id_or_type) self.__events.splice(i,1);
|
56
58
|
break
|
57
59
|
case "string":
|
58
|
-
|
60
|
+
case "object":
|
61
|
+
if(e.type === id_or_type) self.__events.splice(i,1);
|
59
62
|
break
|
60
63
|
}
|
61
64
|
}
|
@@ -63,6 +66,6 @@ var EventEmitter = function(){
|
|
63
66
|
|
64
67
|
};
|
65
68
|
|
66
|
-
if(typeof module !==
|
69
|
+
if(typeof module !== "undefined" && typeof module.exports !== "undefined"){
|
67
70
|
module.exports = EventEmitter;
|
68
71
|
}
|
@@ -41,9 +41,10 @@ module Sinatra
|
|
41
41
|
end
|
42
42
|
|
43
43
|
app.post '/cometio/io' do
|
44
|
+
from = params[:session]
|
45
|
+
halt 400, 'no session' if from.empty?
|
44
46
|
type = params[:type]
|
45
47
|
data = params[:data]
|
46
|
-
from = params[:session]
|
47
48
|
EM::defer do
|
48
49
|
CometIO.emit type, data, from unless type.to_s.empty?
|
49
50
|
end
|
data/sample/Gemfile.lock
CHANGED
data/sinatra-cometio.gemspec
CHANGED
@@ -20,6 +20,6 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency 'sinatra', '>= 1.3.0'
|
21
21
|
gem.add_dependency 'eventmachine', '>= 1.0.0'
|
22
22
|
gem.add_dependency 'json', '>= 1.7.0'
|
23
|
-
gem.add_dependency 'event_emitter', '
|
23
|
+
gem.add_dependency 'event_emitter', '>= 0.2.4'
|
24
24
|
gem.add_dependency 'httparty', '>= 0.10.2'
|
25
25
|
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.3.
|
4
|
+
version: 0.3.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-
|
12
|
+
date: 2013-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra-contrib
|
@@ -80,17 +80,17 @@ dependencies:
|
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ! '>='
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
85
|
+
version: 0.2.4
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: 0.2.4
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: httparty
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|