Skip to content

Commit

Permalink
One more fix for #962, improve error code
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Apr 10, 2013
1 parent f06f720 commit 50e9f76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions modules/jquery/src/main/webapp/jquery/jquery.atmosphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -1468,13 +1468,15 @@ jQuery.atmosphere = function() {
}

if (update) {
// MSIE status can be higher than 1000, Chrome can be 0
// MSIE 9 and lower status can be higher than 1000, Chrome can be 0
if (ajaxRequest.status >= 300 || ajaxRequest.status == 0) {

var status = ajaxRequest.status > 1000 ? ajaxRequest.status = 0 : ajaxRequest.status;
// Allow recovering from cached content.
if (ajaxRequest.status < 400 && _requestCount++ < _request.maxReconnectOnClose) {
if (status < 400 && _requestCount++ < _request.maxReconnectOnClose) {
_reconnect(ajaxRequest, rq, false);
} else {
_onError(ajaxRequest.status, "maxReconnectOnClose reached");
_onError(status, "maxReconnectOnClose reached");
}
return;
}
Expand Down Expand Up @@ -1684,7 +1686,9 @@ jQuery.atmosphere = function() {
function _reconnect(ajaxRequest, request, force) {
if (request.reconnect && force || (request.suspend && request.transport != 'streaming' && _subscribed)) {
if (request.reconnect) {
_response.status = ajaxRequest.status;
var status = ajaxRequest.status > 1000 ? ajaxRequest.status = 0 : ajaxRequest.status;
_response.status = status == 0 ? 204 : status;
_response.reason = status == 0 ? "Server resumed the connection or down." : "OK";
_open('re-opening', request.transport, request);
request.id = setTimeout(function() {
_executeRequest();
Expand Down
2 changes: 1 addition & 1 deletion samples/chat/src/main/webapp/jquery/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $(function () {
var logged = false;
var socket = $.atmosphere;
var subSocket;
var transport = 'websocket';
var transport = 'long-polling';

// We are now ready to cut the request
var request = { url: document.location.toString() + 'chat',
Expand Down

0 comments on commit 50e9f76

Please sign in to comment.