diff options
Diffstat (limited to 'WebContent/VAADIN/jquery.atmosphere.js')
-rw-r--r-- | WebContent/VAADIN/jquery.atmosphere.js | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/WebContent/VAADIN/jquery.atmosphere.js b/WebContent/VAADIN/jquery.atmosphere.js index 2b176668c1..eb57ed6d53 100644 --- a/WebContent/VAADIN/jquery.atmosphere.js +++ b/WebContent/VAADIN/jquery.atmosphere.js @@ -341,12 +341,7 @@ jQuery.atmosphere = function() { _request.ctime = jQuery.now(); if (_request.transport != 'websocket' && _request.transport != 'sse') { - // Gives a chance to the connection to be established before calling the callback - setTimeout(function() { - _open('opening', _request.transport, _request); - }, 500); _executeRequest(); - } else if (_request.transport == 'websocket') { if (!_supportWebsocket()) { _reconnectWithFallbackTransport("Websocket is not supported, using request.fallbackTransport (" + _request.fallbackTransport + ")"); @@ -685,6 +680,8 @@ jQuery.atmosphere = function() { _close(); }; + request.closed = false; + if (_response.error == null) { _response.request = request; var prevState = _response.state; @@ -1025,10 +1022,6 @@ jQuery.atmosphere = function() { jQuery.atmosphere.debug("Using URL: " + location); } - if (webSocketOpened) { - _open('re-opening', "websocket", _request); - } - if (webSocketOpened && !_request.reconnect) { if (_websocket != null) { _clearState(); @@ -1068,9 +1061,7 @@ jQuery.atmosphere = function() { jQuery.atmosphere.debug("Websocket successfully opened"); } - if (!webSocketOpened) { - _open('opening', "websocket", _request); - } + _open('opening', 'websocket', _request); webSocketOpened = true; _websocket.webSocketOpened = webSocketOpened; @@ -1445,10 +1436,14 @@ jQuery.atmosphere = function() { if (_abordingConnection) { return; } + _response.error = null; var skipCallbackInvocation = false; var update = false; + if (rq.transport == 'streaming' && ajaxRequest.readyState == 2) { + _open('opening', rq.transport, rq); + } // Opera doesn't call onerror if the server disconnect. if (jQuery.browser.opera @@ -1483,6 +1478,7 @@ jQuery.atmosphere = function() { // Prevent onerror callback to be called _response.errorHandled = true; _clearState(); + _invokeClose(true); reconnectF(); return; } @@ -1579,6 +1575,11 @@ jQuery.atmosphere = function() { } _verifyStreamingLength(ajaxRequest, rq); + + if (rq.transport == 'streaming' && rq.readyState == 4) { + _invokeClose(true); + reconnectF(); + } } }; ajaxRequest.send(rq.data); @@ -1669,16 +1670,12 @@ jQuery.atmosphere = function() { _response.status = status == 0 ? 204 : status; _response.reason = status == 0 ? "Server resumed the connection or down." : "OK"; - var reconnectInterval = (request.connectTimeout == -1) ? 0 : request.connectTimeout; + var reconnectInterval = request.reconnectInterval; // Reconnect immedialtely - if (!force) { - request.id = setTimeout(function () { - _executeRequest(request); - }, reconnectInterval); - } else { + request.id = setTimeout(function () { _executeRequest(request); - } + }, reconnectInterval); } } } |