Skip to content

Commit

Permalink
Only continue retrying if the connection isn't disconnecting.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Jun 5, 2012
1 parent a07d1a2 commit af2ae94
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 15 deletions.
24 changes: 20 additions & 4 deletions SignalR/Scripts/jquery.signalR.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 69,10 @@
$(connection).trigger(events.onStateChanged, [{ oldState: connection.state, newState: state}]);
connection.state = state;
}
},
isDisconnecting = function (connection) {
return connection.state === signalR.connectionState.disconnecting ||
connection.state === signalR.connectionState.disconnected;
};

signalR = function (url, qs, logging) {
Expand Down Expand Up @@ -715,7 719,9 @@
if (reconnecting) {
// If we were reconnecting, rather than doing initial connect, then try reconnect again
connection.log("EventSource reconnecting");
that.reconnect(connection);
if (isDisconnecting(connection) === false) {
that.reconnect(connection);
}
}
}
return;
Expand Down Expand Up @@ -794,7 800,9 @@

changeState(connection, signalR.connectionState.reconnecting);

that.reconnect(connection);
if (isDisconnecting(connection) === false) {
that.reconnect(connection);
}
}
else {
// The EventSource has closed, either because its close() method was called,
Expand Down Expand Up @@ -871,7 879,9 @@

changeState(connection, signalR.connectionState.reconnecting);

that.reconnect(connection);
if (isDisconnecting(connection) === false) {
that.reconnect(connection);
}
}
});

Expand Down Expand Up @@ -1029,6 1039,10 @@
return;
}

if (isDisconnecting(instance) === true) {
return;
}

if (delay > 0) {
window.setTimeout(function () {
poll(instance, timedOutReceived);
Expand All @@ -1055,7 1069,9 @@
$(instance).trigger(events.onError, [data.responseText]);

window.setTimeout(function () {
poll(instance, true);
if (isDisconnecting(instance) === false) {
poll(instance, true);
}
}, connection.reconnectDelay);
}
});
Expand Down
2 changes: 1 addition & 1 deletion SignalR/Scripts/jquery.signalR.min.js

Large diffs are not rendered by default.

24 changes: 20 additions & 4 deletions samples/SignalR.Hosting.AspNet.Samples/Scripts/jquery.signalR.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 69,10 @@
$(connection).trigger(events.onStateChanged, [{ oldState: connection.state, newState: state}]);
connection.state = state;
}
},
isDisconnecting = function (connection) {
return connection.state === signalR.connectionState.disconnecting ||
connection.state === signalR.connectionState.disconnected;
};

signalR = function (url, qs, logging) {
Expand Down Expand Up @@ -715,7 719,9 @@
if (reconnecting) {
// If we were reconnecting, rather than doing initial connect, then try reconnect again
connection.log("EventSource reconnecting");
that.reconnect(connection);
if (isDisconnecting(connection) === false) {
that.reconnect(connection);
}
}
}
return;
Expand Down Expand Up @@ -794,7 800,9 @@

changeState(connection, signalR.connectionState.reconnecting);

that.reconnect(connection);
if (isDisconnecting(connection) === false) {
that.reconnect(connection);
}
}
else {
// The EventSource has closed, either because its close() method was called,
Expand Down Expand Up @@ -871,7 879,9 @@

changeState(connection, signalR.connectionState.reconnecting);

that.reconnect(connection);
if (isDisconnecting(connection) === false) {
that.reconnect(connection);
}
}
});

Expand Down Expand Up @@ -1029,6 1039,10 @@
return;
}

if (isDisconnecting(instance) === true) {
return;
}

if (delay > 0) {
window.setTimeout(function () {
poll(instance, timedOutReceived);
Expand All @@ -1055,7 1069,9 @@
$(instance).trigger(events.onError, [data.responseText]);

window.setTimeout(function () {
poll(instance, true);
if (isDisconnecting(instance) === false) {
poll(instance, true);
}
}, connection.reconnectDelay);
}
});
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -69,6 69,10 @@
$(connection).trigger(events.onStateChanged, [{ oldState: connection.state, newState: state}]);
connection.state = state;
}
},
isDisconnecting = function (connection) {
return connection.state === signalR.connectionState.disconnecting ||
connection.state === signalR.connectionState.disconnected;
};

signalR = function (url, qs, logging) {
Expand Down Expand Up @@ -715,7 719,9 @@
if (reconnecting) {
// If we were reconnecting, rather than doing initial connect, then try reconnect again
connection.log("EventSource reconnecting");
that.reconnect(connection);
if (isDisconnecting(connection) === false) {
that.reconnect(connection);
}
}
}
return;
Expand Down Expand Up @@ -794,7 800,9 @@

changeState(connection, signalR.connectionState.reconnecting);

that.reconnect(connection);
if (isDisconnecting(connection) === false) {
that.reconnect(connection);
}
}
else {
// The EventSource has closed, either because its close() method was called,
Expand Down Expand Up @@ -871,7 879,9 @@

changeState(connection, signalR.connectionState.reconnecting);

that.reconnect(connection);
if (isDisconnecting(connection) === false) {
that.reconnect(connection);
}
}
});

Expand Down Expand Up @@ -1029,6 1039,10 @@
return;
}

if (isDisconnecting(instance) === true) {
return;
}

if (delay > 0) {
window.setTimeout(function () {
poll(instance, timedOutReceived);
Expand All @@ -1055,7 1069,9 @@
$(instance).trigger(events.onError, [data.responseText]);

window.setTimeout(function () {
poll(instance, true);
if (isDisconnecting(instance) === false) {
poll(instance, true);
}
}, connection.reconnectDelay);
}
});
Expand Down
Loading

0 comments on commit af2ae94

Please sign in to comment.