Skip to content

Commit

Permalink
Ensure SSE & WS will attempt reconnecting multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
halter73 committed Mar 16, 2013
1 parent 35b65d0 commit cdaaa33
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -974,19 +974,22 @@
var transport = signalR.transports[transportName],
that = this;

function isConnectedOrReconnecting() {
return connection.state === signalR.connectionState.connected ||
connection.state === signalR.connectionState.reconnecting;
}

// We should only set a reconnectTimeout if we are currently connected
// and a reconnectTimeout isn't already set.
if (connection.state === signalR.connectionState.connected && !connection._.reconnectTimeout) {
if (isConnectedOrReconnecting() && !connection._.reconnectTimeout) {

connection._.reconnectTimeout = window.setTimeout(function () {
transport.stop(connection);

if (that.ensureReconnectingState(connection)) {
connection.log(transportName + " reconnecting");
transport.start(connection);
}

// Delete the reconnectTimeout so a new one can be created later if needed.
delete connection._.reconnectTimeout;
}, connection.reconnectDelay);
}
},
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -974,19 +974,22 @@
var transport = signalR.transports[transportName],
that = this;

function isConnectedOrReconnecting() {
return connection.state === signalR.connectionState.connected ||
connection.state === signalR.connectionState.reconnecting;
}

// We should only set a reconnectTimeout if we are currently connected
// and a reconnectTimeout isn't already set.
if (connection.state === signalR.connectionState.connected && !connection._.reconnectTimeout) {
if (isConnectedOrReconnecting() && !connection._.reconnectTimeout) {

connection._.reconnectTimeout = window.setTimeout(function () {
transport.stop(connection);

if (that.ensureReconnectingState(connection)) {
connection.log(transportName + " reconnecting");
transport.start(connection);
}

// Delete the reconnectTimeout so a new one can be created later if needed.
delete connection._.reconnectTimeout;
}, connection.reconnectDelay);
}
},
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,22 @@
var transport = signalR.transports[transportName],
that = this;

function isConnectedOrReconnecting() {
return connection.state === signalR.connectionState.connected ||
connection.state === signalR.connectionState.reconnecting;
}

// We should only set a reconnectTimeout if we are currently connected
// and a reconnectTimeout isn't already set.
if (connection.state === signalR.connectionState.connected && !connection._.reconnectTimeout) {
if (isConnectedOrReconnecting() && !connection._.reconnectTimeout) {

connection._.reconnectTimeout = window.setTimeout(function () {
transport.stop(connection);

if (that.ensureReconnectingState(connection)) {
connection.log(transportName + " reconnecting");
transport.start(connection);
}

// Delete the reconnectTimeout so a new one can be created later if needed.
delete connection._.reconnectTimeout;
}, connection.reconnectDelay);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,19 +974,22 @@
var transport = signalR.transports[transportName],
that = this;

function isConnectedOrReconnecting() {
return connection.state === signalR.connectionState.connected ||
connection.state === signalR.connectionState.reconnecting;
}

// We should only set a reconnectTimeout if we are currently connected
// and a reconnectTimeout isn't already set.
if (connection.state === signalR.connectionState.connected && !connection._.reconnectTimeout) {
if (isConnectedOrReconnecting() && !connection._.reconnectTimeout) {

connection._.reconnectTimeout = window.setTimeout(function () {
transport.stop(connection);

if (that.ensureReconnectingState(connection)) {
connection.log(transportName + " reconnecting");
transport.start(connection);
}

// Delete the reconnectTimeout so a new one can be created later if needed.
delete connection._.reconnectTimeout;
}, connection.reconnectDelay);
}
},
Expand Down

0 comments on commit cdaaa33

Please sign in to comment.