Skip to content

Commit

Permalink
Merge branch 'r2.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
pl committed Oct 21, 2013
2 parents 58df000 + 2e9b825 commit e4471cf
Show file tree
Hide file tree
Showing 19 changed files with 163 additions and 83 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 2.1.3 (2013-10-21)

[CHANGED] Updated the json2 library

[FIXED] Catch exceptions when accessing localStorage and parsing its contents

[FIXED] Flush transport cache if it's corrupted

[FIXED] Stop raising exceptions when stats requests fail

[CHANGED] Don't report stats when offline

[CHANGED] Raise an error when trying to send a client event without the `client-` prefix

## 2.1.2 (2013-08-09)

[FIXED] Race condition in SockJS heartbeats
Expand Down
2 changes: 1 addition & 1 deletion JFile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ target_dir './dist'

src_dir './src'

version '2.1.2'
version '2.1.3'

bundle 'pusher.js' do
license 'pusher-licence.js'
Expand Down
2 changes: 1 addition & 1 deletion dist/flashfallback.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Pusher JavaScript Library v2.1.2
* Pusher JavaScript Library v2.1.3
* http://pusherapp.com/
*
* Copyright 2011, Pusher
Expand Down
2 changes: 1 addition & 1 deletion dist/flashfallback.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions dist/json2.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
http://www.JSON.org/json2.js
2011-10-19
json2.js
2013-05-26
Public Domain.
Expand Down Expand Up @@ -159,13 +159,12 @@
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.

var JSON;
if (!JSON) {
if (typeof JSON !== 'object') {
JSON = {};
}

(function () {
'use strict';
'use strict';

function f(n) {
// Format integers to have at least two digits.
Expand All @@ -174,7 +173,7 @@ if (!JSON) {

if (typeof Date.prototype.toJSON !== 'function') {

Date.prototype.toJSON = function (key) {
Date.prototype.toJSON = function () {

return isFinite(this.valueOf())
? this.getUTCFullYear() + '-' +
Expand All @@ -188,7 +187,7 @@ if (!JSON) {

String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function (key) {
Boolean.prototype.toJSON = function () {
return this.valueOf();
};
}
Expand Down Expand Up @@ -485,3 +484,4 @@ if (!JSON) {
};
}
}());

8 changes: 4 additions & 4 deletions dist/json2.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 30 additions & 16 deletions dist/pusher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Pusher JavaScript Library v2.1.2
* Pusher JavaScript Library v2.1.3
* http://pusherapp.com/
*
* Copyright 2013, Pusher
Expand Down Expand Up @@ -509,7 +509,7 @@
}).call(this);

;(function() {
Pusher.VERSION = '2.1.2';
Pusher.VERSION = '2.1.3';
Pusher.PROTOCOL = 6;

// DEPRECATED: WS connection parameters
Expand Down Expand Up @@ -622,6 +622,7 @@

/** Error classes used throughout pusher-js library. */
Pusher.Errors = {
BadEventName: buildExceptionClass("BadEventName"),
UnsupportedTransport: buildExceptionClass("UnsupportedTransport"),
UnsupportedStrategy: buildExceptionClass("UnsupportedStrategy"),
TransportPriorityTooLow: buildExceptionClass("TransportPriorityTooLow"),
Expand Down Expand Up @@ -1169,21 +1170,25 @@
prototype.send = function(sendJSONP, callback) {
var self = this;

if (Pusher.Network.isOnline() === false) {
return false;
}

var data = {};
if (this.sent === 0) {
if (self.sent === 0) {
data = Pusher.Util.extend({
key: this.key,
features: this.options.features,
version: this.options.version
}, this.options.params || {});
key: self.key,
features: self.options.features,
version: self.options.version
}, self.options.params || {});
}
data.session = this.session;
data.timeline = this.events;
data.session = self.session;
data.timeline = self.events;
data = Pusher.Util.filterObject(data, function(v) {
return v !== undefined;
});

this.events = [];
self.events = [];
sendJSONP(data, function(error, result) {
if (!error) {
self.sent++;
Expand Down Expand Up @@ -1226,7 +1231,7 @@
receiver: Pusher.JSONP
};
return Pusher.JSONPRequest.send(params, function(error, result) {
if (result.host) {
if (result && result.host) {
self.host = result.host;
}
if (callback) {
Expand Down Expand Up @@ -1385,9 +1390,13 @@
function fetchTransportInfo() {
var storage = Pusher.Util.getLocalStorage();
if (storage) {
var info = storage.pusherTransport;
if (info) {
return JSON.parse(storage.pusherTransport);
try {
var info = storage.pusherTransport;
if (info) {
return JSON.parse(info);
}
} catch (e) {
flushTransportInfo();
}
}
return null;
Expand All @@ -1402,7 +1411,7 @@
transport: transport,
latency: latency
});
} catch(e) {
} catch (e) {
// catch over quota exceptions raised by localStorage
}
}
Expand All @@ -1413,7 +1422,7 @@
if (storage && storage.pusherTransport) {
try {
delete storage.pusherTransport;
} catch(e) {
} catch (e) {
storage.pusherTransport = undefined;
}
}
Expand Down Expand Up @@ -3361,6 +3370,11 @@

/** Triggers an event */
prototype.trigger = function(event, data) {
if (event.indexOf("client-") !== 0) {
throw new Pusher.Errors.BadEventName(
"Event '" + event + "' does not start with 'client-'"
);
}
return this.pusher.send_event(event, data, this.name);
};

Expand Down
Loading

0 comments on commit e4471cf

Please sign in to comment.