Fixed Intel AMT KVM viewer on Chrome
This commit is contained in:
parent
f8be20be0a
commit
c3a49807dc
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "meshcentral",
|
||||
"version": "0.2.7-k",
|
||||
"version": "0.2.7-m",
|
||||
"keywords": [
|
||||
"Remote Management",
|
||||
"Intel AMT",
|
||||
|
|
|
@ -28,6 +28,45 @@ var CreateKvmDataChannel = function (webchannel, module, keepalive) {
|
|||
obj.rtcKeepAlive = setInterval(obj.xxSendRtcKeepAlive, 30000);
|
||||
}
|
||||
|
||||
// Setup the file reader
|
||||
var fileReader = new FileReader();
|
||||
var fileReaderInuse = false, fileReaderAcc = [];
|
||||
if (fileReader.readAsBinaryString) {
|
||||
// Chrome & Firefox (Draft)
|
||||
fileReader.onload = function (e) { obj.xxOnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsBinaryString(new Blob([fileReaderAcc.shift()])); } }
|
||||
} else if (fileReader.readAsArrayBuffer) {
|
||||
// Chrome & Firefox (Spec)
|
||||
fileReader.onloadend = function (e) { obj.xxOnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsArrayBuffer(fileReaderAcc.shift()); } }
|
||||
}
|
||||
|
||||
obj.xxOnMessage = function (e) {
|
||||
//if (obj.debugmode == 1) { console.log('Recv', e.data); }
|
||||
//if (urlvars && urlvars['webrtctrace']) { console.log('WebRTC-Recv(' + obj.State + '): ', typeof e.data, e.data); }
|
||||
if (typeof e.data == 'string') { if (obj.onControlMsg != null) { obj.onControlMsg(e.data); } return; } // If this is a control message, handle it here.
|
||||
if (typeof e.data == 'object') {
|
||||
if (fileReaderInuse == true) { fileReaderAcc.push(e.data); return; }
|
||||
if (fileReader.readAsBinaryString) {
|
||||
// Chrome & Firefox (Draft)
|
||||
fileReaderInuse = true;
|
||||
fileReader.readAsBinaryString(new Blob([e.data]));
|
||||
} else if (f.readAsArrayBuffer) {
|
||||
// Chrome & Firefox (Spec)
|
||||
fileReaderInuse = true;
|
||||
fileReader.readAsArrayBuffer(e.data);
|
||||
} else {
|
||||
// IE10, readAsBinaryString does not exist, use an alternative.
|
||||
var binary = "", bytes = new Uint8Array(e.data), length = bytes.byteLength;
|
||||
for (var i = 0; i < length; i++) { binary += String.fromCharCode(bytes[i]); }
|
||||
obj.xxOnSocketData(binary);
|
||||
}
|
||||
} else {
|
||||
// If we get a string object, it maybe the WebRTC confirm. Ignore it.
|
||||
//obj.debug("Agent Redir Relay - OnData - " + typeof e.data + " - " + e.data.length);
|
||||
obj.xxOnSocketData(e.data);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
obj.xxOnMessage = function (e) {
|
||||
//if (obj.debugmode == 1) { console.log('Recv', e.data); }
|
||||
//if (urlvars && urlvars['webrtctrace']) { console.log('WebRTC-Recv(' + obj.State + '): ', typeof e.data, e.data); }
|
||||
|
@ -54,7 +93,8 @@ var CreateKvmDataChannel = function (webchannel, module, keepalive) {
|
|||
obj.xxOnSocketData(e.data);
|
||||
}
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
obj.xxOnSocketData = function (data) {
|
||||
if (!data) return;
|
||||
if (typeof data === 'object') {
|
||||
|
|
|
@ -58,22 +58,29 @@ var CreateAmtRemoteIder = function (serverurl) {
|
|||
_Send('C');
|
||||
}
|
||||
|
||||
// Setup the file reader
|
||||
var fileReader = new FileReader();
|
||||
var fileReaderInuse = false, fileReaderAcc = [];
|
||||
if (fileReader.readAsBinaryString) {
|
||||
// Chrome & Firefox (Draft)
|
||||
fileReader.onload = function (e) { _OnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsBinaryString(new Blob([fileReaderAcc.shift()])); } }
|
||||
} else if (fileReader.readAsArrayBuffer) {
|
||||
// Chrome & Firefox (Spec)
|
||||
fileReader.onloadend = function (e) { _OnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsArrayBuffer(fileReaderAcc.shift()); } }
|
||||
}
|
||||
|
||||
function _OnMessage(e) {
|
||||
if (typeof e.data == 'object') {
|
||||
var f = new FileReader();
|
||||
if (f.readAsBinaryString) {
|
||||
if (fileReaderInuse == true) { fileReaderAcc.push(e.data); return; }
|
||||
if (fileReader.readAsBinaryString) {
|
||||
// Chrome & Firefox (Draft)
|
||||
f.onload = function (e) { _OnSocketData(e.target.result); }
|
||||
f.readAsBinaryString(new Blob([e.data]));
|
||||
} else if (f.readAsArrayBuffer) {
|
||||
fileReader.readAsBinaryString(new Blob([e.data]));
|
||||
} else if (fileReader.readAsArrayBuffer) {
|
||||
// Chrome & Firefox (Spec)
|
||||
f.onloadend = function (e) { _OnSocketData(e.target.result); }
|
||||
f.readAsArrayBuffer(e.data);
|
||||
fileReader.readAsArrayBuffer(e.data);
|
||||
} else {
|
||||
// IE10, readAsBinaryString does not exist, use an alternative.
|
||||
var binary = "";
|
||||
var bytes = new Uint8Array(e.data);
|
||||
var length = bytes.byteLength;
|
||||
var binary = "", bytes = new Uint8Array(e.data), length = bytes.byteLength;
|
||||
for (var i = 0; i < length; i++) { binary += String.fromCharCode(bytes[i]); }
|
||||
_OnSocketData(binary);
|
||||
}
|
||||
|
|
|
@ -59,24 +59,33 @@ var CreateAmtRedirect = function (module, authCookie) {
|
|||
if (obj.protocol == 3) obj.xxSend(obj.RedirectStartIder);
|
||||
}
|
||||
|
||||
// Setup the file reader
|
||||
var fileReader = new FileReader();
|
||||
var fileReaderInuse = false, fileReaderAcc = [];
|
||||
if (fileReader.readAsBinaryString) {
|
||||
// Chrome & Firefox (Draft)
|
||||
fileReader.onload = function (e) { obj.xxOnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsBinaryString(new Blob([fileReaderAcc.shift()])); } }
|
||||
} else if (fileReader.readAsArrayBuffer) {
|
||||
// Chrome & Firefox (Spec)
|
||||
fileReader.onloadend = function (e) { obj.xxOnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsArrayBuffer(fileReaderAcc.shift()); } }
|
||||
}
|
||||
|
||||
obj.xxOnMessage = function (e) {
|
||||
//if (obj.debugmode == 1) { console.log('Recv', e.data); }
|
||||
obj.inDataCount++;
|
||||
if (typeof e.data == 'object') {
|
||||
var f = new FileReader();
|
||||
if (f.readAsBinaryString) {
|
||||
if (fileReaderInuse == true) { fileReaderAcc.push(e.data); return; }
|
||||
if (fileReader.readAsBinaryString) {
|
||||
// Chrome & Firefox (Draft)
|
||||
f.onload = function (e) { obj.xxOnSocketData(e.target.result); }
|
||||
f.readAsBinaryString(new Blob([e.data]));
|
||||
fileReaderInuse = true;
|
||||
fileReader.readAsBinaryString(new Blob([e.data]));
|
||||
} else if (f.readAsArrayBuffer) {
|
||||
// Chrome & Firefox (Spec)
|
||||
f.onloadend = function (e) { obj.xxOnSocketData(e.target.result); }
|
||||
f.readAsArrayBuffer(e.data);
|
||||
fileReaderInuse = true;
|
||||
fileReader.readAsArrayBuffer(e.data);
|
||||
} else {
|
||||
// IE10, readAsBinaryString does not exist, use an alternative.
|
||||
var binary = "";
|
||||
var bytes = new Uint8Array(e.data);
|
||||
var length = bytes.byteLength;
|
||||
var binary = "", bytes = new Uint8Array(e.data), length = bytes.byteLength;
|
||||
for (var i = 0; i < length; i++) { binary += String.fromCharCode(bytes[i]); }
|
||||
obj.xxOnSocketData(binary);
|
||||
}
|
||||
|
@ -88,7 +97,6 @@ var CreateAmtRedirect = function (module, authCookie) {
|
|||
};
|
||||
|
||||
obj.xxOnSocketData = function (data) {
|
||||
//if (obj.debugmode == 1) { console.log('Recv', data.length, rstr2hex(data)); }
|
||||
if (!data || obj.connectstate == -1) return;
|
||||
|
||||
if (typeof data === 'object') {
|
||||
|
@ -250,7 +258,7 @@ var CreateAmtRedirect = function (module, authCookie) {
|
|||
obj.xxSend = function (x) {
|
||||
//obj.Debug("Redir Send(" + x.length + "): " + rstr2hex(x));
|
||||
if (obj.socket != null && obj.socket.readyState == WebSocket.OPEN) {
|
||||
//if (obj.debugmode == 1) { console.log('Send', x.length, rstr2hex(x)); }
|
||||
if (obj.debugmode == 1) { console.log('Send', x); }
|
||||
var b = new Uint8Array(x.length);
|
||||
for (var i = 0; i < x.length; ++i) { b[i] = x.charCodeAt(i); }
|
||||
obj.socket.send(b.buffer);
|
||||
|
|
|
@ -130,27 +130,33 @@ var CreateWsmanComm = function (host, port, user, pass, tls) {
|
|||
for (i in obj.pendingAjaxCall) { obj.sendRequest(obj.pendingAjaxCall[i][0], obj.pendingAjaxCall[i][3], obj.pendingAjaxCall[i][4]); }
|
||||
}
|
||||
|
||||
// Setup the file reader
|
||||
var fileReader = new FileReader();
|
||||
var fileReaderInuse = false, fileReaderAcc = [];
|
||||
if (fileReader.readAsBinaryString) {
|
||||
// Chrome & Firefox (Draft)
|
||||
fileReader.onload = function (e) { _OnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsBinaryString(new Blob([fileReaderAcc.shift()])); } }
|
||||
} else if (fileReader.readAsArrayBuffer) {
|
||||
// Chrome & Firefox (Spec)
|
||||
fileReader.onloadend = function (e) { _OnSocketData(e.target.result); if (fileReaderAcc.length == 0) { fileReaderInuse = false; } else { fileReader.readAsArrayBuffer(fileReaderAcc.shift()); } }
|
||||
}
|
||||
|
||||
function _OnMessage(e) {
|
||||
if (typeof e.data == 'object') {
|
||||
var f = new FileReader();
|
||||
if (f.readAsBinaryString) {
|
||||
if (fileReaderInuse == true) { fileReaderAcc.push(e.data); return; }
|
||||
if (fileReader.readAsBinaryString) {
|
||||
// Chrome & Firefox (Draft)
|
||||
f.onload = function (e) { _OnSocketData(e.target.result); }
|
||||
f.readAsBinaryString(new Blob([e.data]));
|
||||
} else if (f.readAsArrayBuffer) {
|
||||
fileReader.readAsBinaryString(new Blob([e.data]));
|
||||
} else if (fileReader.readAsArrayBuffer) {
|
||||
// Chrome & Firefox (Spec)
|
||||
f.onloadend = function (e) { _OnSocketData(e.target.result); }
|
||||
f.readAsArrayBuffer(e.data);
|
||||
fileReader.readAsArrayBuffer(e.data);
|
||||
} else {
|
||||
// IE10, readAsBinaryString does not exist, use an alternative.
|
||||
var binary = "";
|
||||
var bytes = new Uint8Array(e.data);
|
||||
var length = bytes.byteLength;
|
||||
var binary = "", bytes = new Uint8Array(e.data), length = bytes.byteLength;
|
||||
for (var i = 0; i < length; i++) { binary += String.fromCharCode(bytes[i]); }
|
||||
_OnSocketData(binary);
|
||||
}
|
||||
} else if (typeof e.data == 'string') {
|
||||
// We got a string object
|
||||
} else {
|
||||
_OnSocketData(e.data);
|
||||
}
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue