pusher_rails 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +0 -1
- data/CHANGELOG.md +0 -13
- data/README.md +3 -3
- data/pusher_rails.gemspec +2 -2
- data/vendor/assets/javascripts/pusher.js +130 -88
- metadata +9 -13
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3cabf21e41ef487b94bf5fbb948228d57ad343b9
|
4
|
+
data.tar.gz: 01a24e6d002d6d2a22882f9e63bb73c51bccda79
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1020d025a5b2491b67595a4cc7646789984b48c9e4d840da8be9803db4b51c3920c9e3e5ffc2630e1726f3aae241cee5e7e27477254da73f1bd3b7aad2d1e9ea
|
7
|
+
data.tar.gz: 9884af8e5537f39f2fdecaaf5c71a69035ccd24cfc2efe1c49eac11fa01a78638c3f442d9cc124b7838e33a7d9cee24971fa6b9e59bb988d325f508c89142674
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
=====================
|
3
3
|
|
4
4
|
Adds:
|
5
|
-
- [pusher-gem v0.9.
|
6
|
-
- [pusher.js v1.12.
|
5
|
+
- [pusher-gem v0.9.2](https://github.com/pusher/pusher-gem/tree/v0.9.2)
|
6
|
+
- [pusher.js v1.12.0](https://github.com/pusher/pusher-js/tree/v1.12.0)
|
7
7
|
- [backpusher.js](https://github.com/pusher/backpusher)
|
8
8
|
|
9
9
|
This pulls in the *pusher-gem* as well as adding *pusher.js* and *backpusher.js* to the assets pipeline of your Rails 3.1+ app.
|
@@ -21,7 +21,7 @@ Licenses
|
|
21
21
|
========
|
22
22
|
|
23
23
|
/*!
|
24
|
-
* Pusher JavaScript Library v1.12.
|
24
|
+
* Pusher JavaScript Library v1.12.0
|
25
25
|
* http://pusherapp.com/
|
26
26
|
*
|
27
27
|
* Copyright 2011, Pusher
|
data/pusher_rails.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'pusher_rails'
|
6
|
-
s.version = '0.
|
6
|
+
s.version = '0.3.0'
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["David Grandinetti"]
|
9
9
|
s.email = ["dave@wegoto12.com"]
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.description = 'Adds pusher.js/backpusher.js to the asset pipeline and pusher-gem to to your app.'
|
12
12
|
s.homepage = 'https://github.com/dbgrandi/pusher_rails'
|
13
13
|
|
14
|
-
s.add_dependency "pusher", "~> 0.
|
14
|
+
s.add_dependency "pusher", "~> 0.11.3"
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.require_paths = ["lib"]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Pusher JavaScript Library v1.12.
|
2
|
+
* Pusher JavaScript Library v1.12.7
|
3
3
|
* http://pusherapp.com/
|
4
4
|
*
|
5
5
|
* Copyright 2011, Pusher
|
@@ -81,7 +81,7 @@
|
|
81
81
|
},
|
82
82
|
|
83
83
|
subscribeAll: function() {
|
84
|
-
var
|
84
|
+
var channelName;
|
85
85
|
for (channelName in this.channels.channels) {
|
86
86
|
if (this.channels.channels.hasOwnProperty(channelName)) {
|
87
87
|
this.subscribe(channelName);
|
@@ -123,7 +123,8 @@
|
|
123
123
|
},
|
124
124
|
|
125
125
|
checkAppKey: function() {
|
126
|
-
if(this.key
|
126
|
+
if (!this.key) {
|
127
|
+
// do not allow undefined, null or empty string
|
127
128
|
Pusher.warn('Warning', 'You must pass your app key when you instantiate Pusher.');
|
128
129
|
}
|
129
130
|
}
|
@@ -183,11 +184,17 @@
|
|
183
184
|
};
|
184
185
|
|
185
186
|
// Pusher defaults
|
186
|
-
Pusher.VERSION = '1.12.
|
187
|
-
|
187
|
+
Pusher.VERSION = '1.12.7';
|
188
|
+
// WS connection parameters
|
188
189
|
Pusher.host = 'ws.pusherapp.com';
|
189
190
|
Pusher.ws_port = 80;
|
190
191
|
Pusher.wss_port = 443;
|
192
|
+
// SockJS fallback parameters
|
193
|
+
Pusher.sockjs_host = 'sockjs.pusher.com';
|
194
|
+
Pusher.sockjs_http_port = 80
|
195
|
+
Pusher.sockjs_https_port = 443
|
196
|
+
Pusher.sockjs_path = "/pusher"
|
197
|
+
// Other settings
|
191
198
|
Pusher.channel_auth_endpoint = '/pusher/auth';
|
192
199
|
Pusher.cdn_http = 'http://js.pusher.com/'
|
193
200
|
Pusher.cdn_https = 'https://d3dy5gmtp8yhk7.cloudfront.net/'
|
@@ -430,27 +437,25 @@ Example:
|
|
430
437
|
};
|
431
438
|
|
432
439
|
|
433
|
-
|
434
|
-
var
|
435
|
-
var UNSUCCESSFUL_OPEN_ATTEMPT_ADDITIONAL_TIMEOUT = 2000;
|
436
|
-
var UNSUCCESSFUL_CONNECTED_ATTEMPT_ADDITIONAL_TIMEOUT = 2000;
|
440
|
+
var OPEN_TIMEOUT_INCREMENT = 2000;
|
441
|
+
var CONNECTED_TIMEOUT_INCREMENT = 2000;
|
437
442
|
|
438
|
-
var
|
439
|
-
var
|
440
|
-
var MAX_CONNECTED_ATTEMPT_TIMEOUT = 5 * UNSUCCESSFUL_CONNECTED_ATTEMPT_ADDITIONAL_TIMEOUT;
|
443
|
+
var MAX_OPEN_TIMEOUT = 10000;
|
444
|
+
var MAX_CONNECTED_TIMEOUT = 10000;
|
441
445
|
|
442
446
|
function resetConnectionParameters(connection) {
|
443
447
|
connection.connectionWait = 0;
|
444
448
|
|
445
|
-
if (Pusher.TransportType === '
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
449
|
+
if (Pusher.TransportType === 'native') {
|
450
|
+
connection.openTimeout = 4000;
|
451
|
+
} else if (Pusher.TransportType === 'flash') {
|
452
|
+
connection.openTimeout = 7000;
|
453
|
+
} else { // SockJS
|
454
|
+
connection.openTimeout = 6000;
|
450
455
|
}
|
451
456
|
connection.connectedTimeout = 2000;
|
452
457
|
connection.connectionSecure = connection.compulsorySecure;
|
453
|
-
connection.
|
458
|
+
connection.failedAttempts = 0;
|
454
459
|
}
|
455
460
|
|
456
461
|
function Connection(key, options) {
|
@@ -458,6 +463,7 @@ Example:
|
|
458
463
|
|
459
464
|
Pusher.EventsDispatcher.call(this);
|
460
465
|
|
466
|
+
this.ping = true
|
461
467
|
this.options = Pusher.Util.extend({encrypted: false}, options);
|
462
468
|
|
463
469
|
this.netInfo = new Pusher.NetInfo();
|
@@ -497,22 +503,25 @@ Example:
|
|
497
503
|
},
|
498
504
|
|
499
505
|
waitingPre: function() {
|
500
|
-
if (self.
|
501
|
-
self.
|
502
|
-
|
506
|
+
if (self.netInfo.isOnLine()) {
|
507
|
+
if (self.failedAttempts < 2) {
|
508
|
+
updateState('connecting');
|
509
|
+
} else {
|
510
|
+
updateState('unavailable');
|
511
|
+
// Delay 10s between connection attempts on entering unavailable
|
512
|
+
self.connectionWait = 10000;
|
513
|
+
}
|
503
514
|
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
updateState('unavailable');
|
508
|
-
}
|
515
|
+
if (self.connectionWait > 0) {
|
516
|
+
self.emit('connecting_in', connectionDelay());
|
517
|
+
}
|
509
518
|
|
510
|
-
// When in the unavailable state we attempt to connect, but don't
|
511
|
-
// broadcast that fact
|
512
|
-
if (self.netInfo.isOnLine()) {
|
513
519
|
self._waitingTimer = setTimeout(function() {
|
520
|
+
// Even when unavailable we try connecting (not changing state)
|
514
521
|
self._machine.transition('connecting');
|
515
522
|
}, connectionDelay());
|
523
|
+
} else {
|
524
|
+
updateState('unavailable');
|
516
525
|
}
|
517
526
|
},
|
518
527
|
|
@@ -530,12 +539,27 @@ Example:
|
|
530
539
|
return;
|
531
540
|
}
|
532
541
|
|
533
|
-
var
|
534
|
-
Pusher.
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
542
|
+
var path = connectPath(self.key);
|
543
|
+
if (Pusher.TransportType === 'sockjs') {
|
544
|
+
Pusher.debug('Connecting to sockjs', Pusher.sockjs);
|
545
|
+
var url = buildSockJSURL(self.connectionSecure);
|
546
|
+
|
547
|
+
self.ping = false
|
548
|
+
self.socket = new SockJS(url);
|
549
|
+
self.socket.onopen = function() {
|
550
|
+
// SockJS does not yet support custom paths and query params
|
551
|
+
self.socket.send(JSON.stringify({path: path}));
|
552
|
+
self._machine.transition('open');
|
553
|
+
}
|
554
|
+
} else {
|
555
|
+
var url = connectBaseURL(self.connectionSecure) + path;
|
556
|
+
Pusher.debug('Connecting', url);
|
557
|
+
self.socket = new Pusher.Transport(url);
|
558
|
+
self.socket.onopen = function() {
|
559
|
+
self._machine.transition('open');
|
560
|
+
}
|
561
|
+
}
|
562
|
+
|
539
563
|
self.socket.onclose = transitionToWaiting;
|
540
564
|
self.socket.onerror = ws_onError;
|
541
565
|
|
@@ -639,44 +663,45 @@ Example:
|
|
639
663
|
-----------------------------------------------*/
|
640
664
|
|
641
665
|
function updateConnectionParameters() {
|
642
|
-
if (self.
|
643
|
-
self.
|
644
|
-
}
|
645
|
-
|
646
|
-
if (self.openTimeout < MAX_OPEN_ATTEMPT_TIMEOUT) {
|
647
|
-
self.openTimeout += UNSUCCESSFUL_OPEN_ATTEMPT_ADDITIONAL_TIMEOUT;
|
666
|
+
if (self.openTimeout < MAX_OPEN_TIMEOUT) {
|
667
|
+
self.openTimeout += OPEN_TIMEOUT_INCREMENT;
|
648
668
|
}
|
649
669
|
|
650
|
-
if (self.connectedTimeout <
|
651
|
-
self.connectedTimeout +=
|
670
|
+
if (self.connectedTimeout < MAX_CONNECTED_TIMEOUT) {
|
671
|
+
self.connectedTimeout += CONNECTED_TIMEOUT_INCREMENT;
|
652
672
|
}
|
653
673
|
|
674
|
+
// Toggle between ws & wss
|
654
675
|
if (self.compulsorySecure !== true) {
|
655
676
|
self.connectionSecure = !self.connectionSecure;
|
656
677
|
}
|
657
678
|
|
658
|
-
self.
|
679
|
+
self.failedAttempts++;
|
659
680
|
}
|
660
681
|
|
661
|
-
function
|
662
|
-
|
663
|
-
var
|
664
|
-
|
665
|
-
|
666
|
-
// been loaded via HTTPS.
|
667
|
-
//
|
668
|
-
// FUTURE: Always connect using SSL.
|
669
|
-
//
|
670
|
-
if (isSecure || document.location.protocol === 'https:') {
|
671
|
-
port = Pusher.wss_port;
|
672
|
-
protocol = 'wss://';
|
673
|
-
}
|
682
|
+
function connectBaseURL(isSecure) {
|
683
|
+
// Always connect with SSL if the current page served over https
|
684
|
+
var ssl = (isSecure || document.location.protocol === 'https:');
|
685
|
+
var port = ssl ? Pusher.wss_port : Pusher.ws_port;
|
686
|
+
var scheme = ssl ? 'wss://' : 'ws://';
|
674
687
|
|
675
|
-
|
688
|
+
return scheme + Pusher.host + ':' + port;
|
689
|
+
}
|
676
690
|
|
677
|
-
|
691
|
+
function connectPath(key) {
|
692
|
+
var flash = (Pusher.TransportType === "flash") ? "true" : "false";
|
693
|
+
var path = '/app/' + key + '?protocol=5&client=js'
|
678
694
|
+ '&version=' + Pusher.VERSION
|
679
695
|
+ '&flash=' + flash;
|
696
|
+
return path;
|
697
|
+
}
|
698
|
+
|
699
|
+
function buildSockJSURL(isSecure) {
|
700
|
+
var ssl = (isSecure || document.location.protocol === 'https:');
|
701
|
+
var port = ssl ? Pusher.sockjs_https_port : Pusher.sockjs_http_port;
|
702
|
+
var scheme = ssl ? 'https://' : 'http://';
|
703
|
+
|
704
|
+
return scheme + Pusher.sockjs_host + ':' + port + Pusher.sockjs_path;
|
680
705
|
}
|
681
706
|
|
682
707
|
// callback for close and retry. Used on timeouts.
|
@@ -687,13 +712,15 @@ Example:
|
|
687
712
|
function resetActivityCheck() {
|
688
713
|
if (self._activityTimer) { clearTimeout(self._activityTimer); }
|
689
714
|
// Send ping after inactivity
|
690
|
-
self.
|
691
|
-
self.send_event('pusher:ping', {})
|
692
|
-
// Wait for pong response
|
715
|
+
if (self.ping) {
|
693
716
|
self._activityTimer = setTimeout(function() {
|
694
|
-
self.
|
695
|
-
|
696
|
-
|
717
|
+
self.send_event('pusher:ping', {})
|
718
|
+
// Wait for pong response
|
719
|
+
self._activityTimer = setTimeout(function() {
|
720
|
+
self.socket.close();
|
721
|
+
}, (self.options.pong_timeout || Pusher.pong_timeout))
|
722
|
+
}, (self.options.activity_timeout || Pusher.activity_timeout))
|
723
|
+
}
|
697
724
|
}
|
698
725
|
|
699
726
|
function stopActivityCheck() {
|
@@ -723,11 +750,6 @@ Example:
|
|
723
750
|
WebSocket Callbacks
|
724
751
|
-----------------------------------------------*/
|
725
752
|
|
726
|
-
// no-op, as we only care when we get pusher:connection_established
|
727
|
-
function ws_onopen() {
|
728
|
-
self._machine.transition('open');
|
729
|
-
};
|
730
|
-
|
731
753
|
function handleCloseCode(code, message) {
|
732
754
|
// first inform the end-developer of this error
|
733
755
|
self.emit('error', {type: 'PusherError', data: {code: code, message: message}});
|
@@ -998,22 +1020,26 @@ Example:
|
|
998
1020
|
|
999
1021
|
var Members = function(channel) {
|
1000
1022
|
var self = this;
|
1023
|
+
var channelData = null;
|
1001
1024
|
|
1002
1025
|
var reset = function() {
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1026
|
+
self._members_map = {};
|
1027
|
+
self.count = 0;
|
1028
|
+
self.me = null;
|
1029
|
+
channelData = null;
|
1030
|
+
};
|
1031
|
+
reset();
|
1032
|
+
|
1033
|
+
var subscriptionSucceeded = function(subscriptionData) {
|
1034
|
+
self._members_map = subscriptionData.presence.hash;
|
1035
|
+
self.count = subscriptionData.presence.count;
|
1036
|
+
self.me = self.get(channelData.user_id);
|
1037
|
+
channel.emit('pusher:subscription_succeeded', self);
|
1006
1038
|
};
|
1007
|
-
reset.call(this);
|
1008
1039
|
|
1009
1040
|
channel.bind('pusher_internal:authorized', function(authorizedData) {
|
1010
|
-
|
1011
|
-
channel.bind("pusher_internal:subscription_succeeded",
|
1012
|
-
self._members_map = subscriptionData.presence.hash;
|
1013
|
-
self.count = subscriptionData.presence.count;
|
1014
|
-
self.me = self.get(channelData.user_id);
|
1015
|
-
channel.emit('pusher:subscription_succeeded', self);
|
1016
|
-
});
|
1041
|
+
channelData = JSON.parse(authorizedData.channel_data);
|
1042
|
+
channel.bind("pusher_internal:subscription_succeeded", subscriptionSucceeded);
|
1017
1043
|
});
|
1018
1044
|
|
1019
1045
|
channel.bind('pusher_internal:member_added', function(data) {
|
@@ -1035,7 +1061,8 @@ Example:
|
|
1035
1061
|
});
|
1036
1062
|
|
1037
1063
|
channel.bind('pusher_internal:disconnected', function() {
|
1038
|
-
reset
|
1064
|
+
reset();
|
1065
|
+
channel.unbind("pusher_internal:subscription_succeeded", subscriptionSucceeded);
|
1039
1066
|
});
|
1040
1067
|
};
|
1041
1068
|
|
@@ -1070,6 +1097,7 @@ Example:
|
|
1070
1097
|
return channel;
|
1071
1098
|
};
|
1072
1099
|
}).call(this);
|
1100
|
+
|
1073
1101
|
;(function() {
|
1074
1102
|
Pusher.Channel.Authorizer = function(channel, type, options) {
|
1075
1103
|
this.channel = channel;
|
@@ -1224,9 +1252,22 @@ var _require = (function() {
|
|
1224
1252
|
deps.push(root + '/json2' + Pusher.dependency_suffix + '.js');
|
1225
1253
|
}
|
1226
1254
|
if (!window['WebSocket']) {
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1255
|
+
var flashSupported;
|
1256
|
+
try {
|
1257
|
+
flashSupported = Boolean(new ActiveXObject('ShockwaveFlash.ShockwaveFlash'));
|
1258
|
+
} catch (e) {
|
1259
|
+
flashSupported = navigator.mimeTypes["application/x-shockwave-flash"] !== undefined;
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
if (flashSupported) {
|
1263
|
+
// Try to use web-socket-js (flash WebSocket emulation)
|
1264
|
+
window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION = true;
|
1265
|
+
window.WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR = true;
|
1266
|
+
deps.push(root + '/flashfallback' + Pusher.dependency_suffix + '.js');
|
1267
|
+
} else {
|
1268
|
+
// Use SockJS when Flash is not available
|
1269
|
+
deps.push(root + '/sockjs' + Pusher.dependency_suffix + '.js');
|
1270
|
+
}
|
1230
1271
|
}
|
1231
1272
|
|
1232
1273
|
var initialize = function() {
|
@@ -1249,9 +1290,9 @@ var _require = (function() {
|
|
1249
1290
|
})
|
1250
1291
|
WebSocket.__initialize();
|
1251
1292
|
} else {
|
1252
|
-
// Flash
|
1253
|
-
Pusher.Transport =
|
1254
|
-
Pusher.TransportType = '
|
1293
|
+
// Flash fallback was not loaded, using SockJS
|
1294
|
+
Pusher.Transport = window.SockJS;
|
1295
|
+
Pusher.TransportType = 'sockjs';
|
1255
1296
|
Pusher.ready();
|
1256
1297
|
}
|
1257
1298
|
}
|
@@ -1276,3 +1317,4 @@ var _require = (function() {
|
|
1276
1317
|
initializeOnDocumentBody();
|
1277
1318
|
}
|
1278
1319
|
})();
|
1320
|
+
|
metadata
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- David Grandinetti
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-03-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: pusher
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
19
|
+
version: 0.11.3
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
26
|
+
version: 0.11.3
|
30
27
|
description: Adds pusher.js/backpusher.js to the asset pipeline and pusher-gem to
|
31
28
|
to your app.
|
32
29
|
email:
|
@@ -44,26 +41,25 @@ files:
|
|
44
41
|
- vendor/assets/javascripts/pusher.js
|
45
42
|
homepage: https://github.com/dbgrandi/pusher_rails
|
46
43
|
licenses: []
|
44
|
+
metadata: {}
|
47
45
|
post_install_message:
|
48
46
|
rdoc_options: []
|
49
47
|
require_paths:
|
50
48
|
- lib
|
51
49
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
50
|
requirements:
|
54
|
-
- -
|
51
|
+
- - '>='
|
55
52
|
- !ruby/object:Gem::Version
|
56
53
|
version: '0'
|
57
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
55
|
requirements:
|
60
|
-
- -
|
56
|
+
- - '>='
|
61
57
|
- !ruby/object:Gem::Version
|
62
58
|
version: '0'
|
63
59
|
requirements: []
|
64
60
|
rubyforge_project:
|
65
|
-
rubygems_version:
|
61
|
+
rubygems_version: 2.0.3
|
66
62
|
signing_key:
|
67
|
-
specification_version:
|
63
|
+
specification_version: 4
|
68
64
|
summary: Pusher integration for Rails 3.1+
|
69
65
|
test_files: []
|