message_bus 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of message_bus might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/assets/message-bus.js +51 -23
- data/lib/message_bus/version.rb +1 -1
- data/vendor/assets/javascripts/message-bus.js +51 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 740688dfebf685690c2df41d642b6d0d642a537f
|
4
|
+
data.tar.gz: e33e81a4348f43cd7c5bff4005ee0741a66b0e05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29e24274cc3c2be1bcdf8b937151bdb5e74797135895c2932353a2949ed9e5a73ee42d8605e0d1a48863e012efffdbaf4810e036c723f72e2bd6faea8c08a2bb
|
7
|
+
data.tar.gz: b199a7e3a01811b295d973aa6b8611bd614bda39242424675a5903461535e3f4f27da1cf7a676caaafe2fafb0c310116dfd16f67e324f2f67f191cd23e4f4b98
|
data/CHANGELOG
CHANGED
data/assets/message-bus.js
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
window.MessageBus = (function() {
|
11
11
|
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
|
12
12
|
var callbacks, clientId, failCount, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl;
|
13
|
-
var me, started, stopped, longPoller, pollTimeout;
|
13
|
+
var me, started, stopped, longPoller, pollTimeout, paused, later;
|
14
14
|
|
15
15
|
uniqueId = function() {
|
16
16
|
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
@@ -28,6 +28,8 @@ window.MessageBus = (function() {
|
|
28
28
|
interval = null;
|
29
29
|
failCount = 0;
|
30
30
|
baseUrl = "/";
|
31
|
+
paused = false;
|
32
|
+
later = [];
|
31
33
|
|
32
34
|
var hiddenProperty;
|
33
35
|
|
@@ -54,6 +56,35 @@ window.MessageBus = (function() {
|
|
54
56
|
var totalAjaxCalls = 0;
|
55
57
|
var lastAjax;
|
56
58
|
|
59
|
+
var processMessages = function(messages) {
|
60
|
+
var gotDate = false;
|
61
|
+
if (!messages) return false; // server unexpectedly closed connection
|
62
|
+
|
63
|
+
$.each(messages,function(_,message) {
|
64
|
+
gotData = true;
|
65
|
+
$.each(callbacks, function(_,callback) {
|
66
|
+
if (callback.channel === message.channel) {
|
67
|
+
callback.last_id = message.message_id;
|
68
|
+
try {
|
69
|
+
callback.func(message.data);
|
70
|
+
}
|
71
|
+
catch(e){
|
72
|
+
if(console.log) {
|
73
|
+
console.log("MESSAGE BUS FAIL: callback " + callback.channel + " caused exception " + e.message);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
if (message.channel === "/__status") {
|
78
|
+
if (message.data[callback.channel] !== undefined) {
|
79
|
+
callback.last_id = message.data[callback.channel];
|
80
|
+
}
|
81
|
+
}
|
82
|
+
});
|
83
|
+
});
|
84
|
+
|
85
|
+
return gotData;
|
86
|
+
};
|
87
|
+
|
57
88
|
longPoller = function(poll,data){
|
58
89
|
var gotData = false;
|
59
90
|
var aborted = false;
|
@@ -71,28 +102,15 @@ window.MessageBus = (function() {
|
|
71
102
|
},
|
72
103
|
success: function(messages) {
|
73
104
|
failCount = 0;
|
74
|
-
if (
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
catch(e){
|
84
|
-
if(console.log) {
|
85
|
-
console.log("MESSAGE BUS FAIL: callback " + callback.channel + " caused exception " + e.message);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}
|
89
|
-
if (message.channel === "/__status") {
|
90
|
-
if (message.data[callback.channel] !== undefined) {
|
91
|
-
callback.last_id = message.data[callback.channel];
|
92
|
-
}
|
93
|
-
}
|
94
|
-
});
|
95
|
-
});
|
105
|
+
if (paused) {
|
106
|
+
if (messages) {
|
107
|
+
$.each(messages, function(_,message) {
|
108
|
+
later.push(messages);
|
109
|
+
});
|
110
|
+
}
|
111
|
+
} else {
|
112
|
+
gotData = processMessages(messages);
|
113
|
+
}
|
96
114
|
},
|
97
115
|
error: function(xhr, textStatus, err) {
|
98
116
|
if(textStatus === "abort") {
|
@@ -157,6 +175,16 @@ window.MessageBus = (function() {
|
|
157
175
|
console.log("Last ajax call: " + (new Date() - lastAjax) / 1000 + " seconds ago") ;
|
158
176
|
},
|
159
177
|
|
178
|
+
pause: function() {
|
179
|
+
paused = true;
|
180
|
+
},
|
181
|
+
|
182
|
+
resume: function() {
|
183
|
+
paused = false;
|
184
|
+
processMessages(later);
|
185
|
+
later = [];
|
186
|
+
},
|
187
|
+
|
160
188
|
stop: function() {
|
161
189
|
stopped = true;
|
162
190
|
started = false;
|
data/lib/message_bus/version.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
window.MessageBus = (function() {
|
11
11
|
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
|
12
12
|
var callbacks, clientId, failCount, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl;
|
13
|
-
var me, started, stopped, longPoller, pollTimeout;
|
13
|
+
var me, started, stopped, longPoller, pollTimeout, paused, later;
|
14
14
|
|
15
15
|
uniqueId = function() {
|
16
16
|
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
@@ -28,6 +28,8 @@ window.MessageBus = (function() {
|
|
28
28
|
interval = null;
|
29
29
|
failCount = 0;
|
30
30
|
baseUrl = "/";
|
31
|
+
paused = false;
|
32
|
+
later = [];
|
31
33
|
|
32
34
|
var hiddenProperty;
|
33
35
|
|
@@ -54,6 +56,35 @@ window.MessageBus = (function() {
|
|
54
56
|
var totalAjaxCalls = 0;
|
55
57
|
var lastAjax;
|
56
58
|
|
59
|
+
var processMessages = function(messages) {
|
60
|
+
var gotDate = false;
|
61
|
+
if (!messages) return false; // server unexpectedly closed connection
|
62
|
+
|
63
|
+
$.each(messages,function(_,message) {
|
64
|
+
gotData = true;
|
65
|
+
$.each(callbacks, function(_,callback) {
|
66
|
+
if (callback.channel === message.channel) {
|
67
|
+
callback.last_id = message.message_id;
|
68
|
+
try {
|
69
|
+
callback.func(message.data);
|
70
|
+
}
|
71
|
+
catch(e){
|
72
|
+
if(console.log) {
|
73
|
+
console.log("MESSAGE BUS FAIL: callback " + callback.channel + " caused exception " + e.message);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
if (message.channel === "/__status") {
|
78
|
+
if (message.data[callback.channel] !== undefined) {
|
79
|
+
callback.last_id = message.data[callback.channel];
|
80
|
+
}
|
81
|
+
}
|
82
|
+
});
|
83
|
+
});
|
84
|
+
|
85
|
+
return gotData;
|
86
|
+
};
|
87
|
+
|
57
88
|
longPoller = function(poll,data){
|
58
89
|
var gotData = false;
|
59
90
|
var aborted = false;
|
@@ -71,28 +102,15 @@ window.MessageBus = (function() {
|
|
71
102
|
},
|
72
103
|
success: function(messages) {
|
73
104
|
failCount = 0;
|
74
|
-
if (
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
catch(e){
|
84
|
-
if(console.log) {
|
85
|
-
console.log("MESSAGE BUS FAIL: callback " + callback.channel + " caused exception " + e.message);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}
|
89
|
-
if (message.channel === "/__status") {
|
90
|
-
if (message.data[callback.channel] !== undefined) {
|
91
|
-
callback.last_id = message.data[callback.channel];
|
92
|
-
}
|
93
|
-
}
|
94
|
-
});
|
95
|
-
});
|
105
|
+
if (paused) {
|
106
|
+
if (messages) {
|
107
|
+
$.each(messages, function(_,message) {
|
108
|
+
later.push(messages);
|
109
|
+
});
|
110
|
+
}
|
111
|
+
} else {
|
112
|
+
gotData = processMessages(messages);
|
113
|
+
}
|
96
114
|
},
|
97
115
|
error: function(xhr, textStatus, err) {
|
98
116
|
if(textStatus === "abort") {
|
@@ -157,6 +175,16 @@ window.MessageBus = (function() {
|
|
157
175
|
console.log("Last ajax call: " + (new Date() - lastAjax) / 1000 + " seconds ago") ;
|
158
176
|
},
|
159
177
|
|
178
|
+
pause: function() {
|
179
|
+
paused = true;
|
180
|
+
},
|
181
|
+
|
182
|
+
resume: function() {
|
183
|
+
paused = false;
|
184
|
+
processMessages(later);
|
185
|
+
later = [];
|
186
|
+
},
|
187
|
+
|
160
188
|
stop: function() {
|
161
189
|
stopped = true;
|
162
190
|
started = false;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: message_bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|