Skip to content

Commit

Permalink
Update the Pusher JS client to version 2.1.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
tristandunn committed Jan 10, 2014
1 parent 3b82c31 commit bd14981
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.13.0 — Unreleased

* Remove deprecated configuration options. (Tristan Dunn)
* Update the Pusher JS client to version 2.1.6. (Tristan Dunn)

## 0.12.0 — December 21, 2013

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Pusher JavaScript Library v2.1.5
* Pusher JavaScript Library v2.1.6
* http://pusherapp.com/
*
* Copyright 2013, Pusher
Expand Down Expand Up @@ -599,7 +599,7 @@
}).call(this);

;(function() {
Pusher.VERSION = '2.1.5';
Pusher.VERSION = '2.1.6';
Pusher.PROTOCOL = 7;

// DEPRECATED: WS connection parameters
Expand Down Expand Up @@ -2452,7 +2452,8 @@
cached: returnWithOriginalContext(function(context, ttl, strategy){
return new Pusher.CachedStrategy(strategy, context.transports, {
ttl: ttl,
timeline: context.timeline
timeline: context.timeline,
encrypted: context.encrypted
});
}),

Expand Down Expand Up @@ -2607,6 +2608,9 @@
message = this.decodeMessage(message);

if (message.event === "pusher:connection_established") {
if (!message.data.activity_timeout) {
throw "No activity timeout specified in handshake";
}
return {
action: "connected",
id: message.data.socket_id,
Expand Down Expand Up @@ -2956,6 +2960,9 @@
});
Pusher.Network.bind("offline", function() {
self.timeline.info({ netinfo: "offline" });
if (self.state === "connected") {
self.sendActivityCheck();
}
});

this.updateStrategy();
Expand Down Expand Up @@ -3027,6 +3034,7 @@
self.runner = self.strategy.connect(0, callback);
} else {
if (handshake.action === "error") {
self.emit("error", { type: "HandshakeError", error: handshake.error });
self.timeline.error({ handshakeError: handshake.error });
} else {
self.abortConnecting(); // we don't support switching connections yet
Expand Down Expand Up @@ -3105,26 +3113,30 @@
}
};

/** @private */
prototype.sendActivityCheck = function() {
var self = this;
self.stopActivityCheck();
self.send_event('pusher:ping', {});
// wait for pong response
self.activityTimer = new Pusher.Timer(
self.options.pongTimeout,
function() {
self.timeline.error({ pong_timed_out: self.options.pongTimeout });
self.retryIn(0);
}
);
};

/** @private */
prototype.resetActivityCheck = function() {
this.stopActivityCheck();
var self = this;
self.stopActivityCheck();
// send ping after inactivity
if (!this.connection.supportsPing()) {
var self = this;
self.activityTimer = new Pusher.Timer(
self.activityTimeout,
function() {
self.send_event('pusher:ping', {});
// wait for pong response
self.activityTimer = new Pusher.Timer(
self.options.pongTimeout,
function() {
self.timeline.error({ pong_timed_out: self.options.pongTimeout });
self.retryIn(0);
}
);
}
);
if (!self.connection.supportsPing()) {
self.activityTimer = new Pusher.Timer(self.activityTimeout, function() {
self.sendActivityCheck();
});
}
};

Expand Down
2 changes: 1 addition & 1 deletion features/support/application/views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ul></ul>
</section>

<script src="/javascripts/vendor/pusher-2.1.5.js"></script>
<script src="/javascripts/vendor/pusher-2.1.6.js"></script>
<script>
window.addEventListener("DOMContentLoaded", function() {
// Create the client instance using the PusherFake server.
Expand Down
2 changes: 1 addition & 1 deletion lib/pusher-fake/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def emit(event, data = {}, channel = nil)

# Notify the Pusher client that a connection has been established.
def establish
emit("pusher:connection_established", socket_id: socket.object_id)
emit("pusher:connection_established", socket_id: socket.object_id, activity_timeout: 120)
end

# Process an event.
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/pusher-fake/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@

it "emits the connection established event with the socket ID" do
subject.establish
subject.should have_received(:emit).with("pusher:connection_established", socket_id: socket.object_id)
subject.should have_received(:emit)
.with("pusher:connection_established", socket_id: socket.object_id, activity_timeout: 120)
end
end

Expand Down

0 comments on commit bd14981

Please sign in to comment.