FIX: Not all browsers send onreadystatechange for new data (Opera doesn't)

This commit is contained in:
Michael Jumper
2011-02-18 23:26:47 -08:00
parent 68fd27e1bb
commit bdde602f71

View File

@@ -295,6 +295,7 @@ function GuacamoleClient(display, tunnelURL) {
function handleResponse(xmlhttprequest) {
var interval = null;
var nextRequest = null;
var instructionStart = 0;
@@ -310,6 +311,12 @@ function GuacamoleClient(display, tunnelURL) {
if (xmlhttprequest.readyState == 3 ||
xmlhttprequest.readyState == 4) {
// Also poll every 30ms (some browsers don't repeatedly call onreadystatechange for new data)
if (xmlhttprequest.readyState == 3 && interval == null)
interval = setInterval(parseResponse, 30);
else if (xmlhttprequest.readyState == 4 && interval != null)
clearInterval(interval);
// Halt on error during request
if (xmlhttprequest.status == 0) {
showError("Request canceled by browser.");