sinatra-cometio 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/lib/js/cometio.js +9 -8
- data/lib/js/event_emitter.js +3 -3
- data/lib/sinatra-cometio/version.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/lib/js/cometio.js
CHANGED
@@ -31,7 +31,7 @@ var CometIO = function(){
|
|
31
31
|
self.emit("connect", self.session);
|
32
32
|
});
|
33
33
|
running = true;
|
34
|
-
|
34
|
+
get();
|
35
35
|
return self;
|
36
36
|
};
|
37
37
|
|
@@ -40,23 +40,24 @@ var CometIO = function(){
|
|
40
40
|
self.removeListener("__session_id");
|
41
41
|
};
|
42
42
|
|
43
|
-
|
43
|
+
var get = function(){
|
44
44
|
if(!running) return;
|
45
45
|
$.ajax(
|
46
46
|
{
|
47
47
|
url : self.url,
|
48
48
|
data : {session : self.session},
|
49
49
|
success : function(data_arr){
|
50
|
-
if(typeof data_arr
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
if(data_arr !== null || typeof data_arr !== "undefined" || !!data_arr.length){
|
51
|
+
for(var i = 0; i < data_arr.length; i++){
|
52
|
+
var data = data_arr[i];
|
53
|
+
if(data) self.emit(data.type, data.data);
|
54
|
+
}
|
54
55
|
}
|
55
|
-
|
56
|
+
get();
|
56
57
|
},
|
57
58
|
error : function(req, stat, e){
|
58
59
|
self.emit("error", "CometIO get error");
|
59
|
-
setTimeout(
|
60
|
+
setTimeout(get, 10000);
|
60
61
|
},
|
61
62
|
complete : function(e){
|
62
63
|
},
|
data/lib/js/event_emitter.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
// event_emitter.js v0.0.
|
2
|
-
// https://github.com/shokai/
|
1
|
+
// event_emitter.js v0.0.7
|
2
|
+
// https://github.com/shokai/event_emitter.js
|
3
3
|
// (c) 2013 Sho Hashimoto <hashimoto@shokai.org>
|
4
4
|
// The MIT License
|
5
5
|
var EventEmitter = function(){
|
@@ -7,7 +7,7 @@ var EventEmitter = function(){
|
|
7
7
|
this.apply = function(target, prefix){
|
8
8
|
if(!prefix) prefix = "";
|
9
9
|
for(var func in self){
|
10
|
-
if(self.hasOwnProperty(func)){
|
10
|
+
if(self.hasOwnProperty(func) && func !== "apply"){
|
11
11
|
target[prefix+func] = this[func];
|
12
12
|
}
|
13
13
|
}
|
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.6
|
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-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|