mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-27 02:04:30 +03:00
Improved websocket speed for MSTSC.js bitmaps.
This commit is contained in:
parent
8c53349a2a
commit
cc67742d3a
4
mstsc.js
4
mstsc.js
@ -84,7 +84,9 @@ module.exports.CreateMstscRelay = function (parent, db, ws, req, args, domain, u
|
|||||||
}).on('connect', function () {
|
}).on('connect', function () {
|
||||||
send(['rdp-connect']);
|
send(['rdp-connect']);
|
||||||
}).on('bitmap', function (bitmap) {
|
}).on('bitmap', function (bitmap) {
|
||||||
send(['rdp-bitmap', bitmap]);
|
try { ws.send(bitmap.data); } catch (ex) { } // Send the bitmap data as binary
|
||||||
|
delete bitmap.data;
|
||||||
|
send(['rdp-bitmap', bitmap]); // Send the bitmap metadata seperately, without bitmap data.
|
||||||
}).on('close', function () {
|
}).on('close', function () {
|
||||||
send(['rdp-close']);
|
send(['rdp-close']);
|
||||||
}).on('error', function (err) {
|
}).on('error', function (err) {
|
||||||
|
@ -129,6 +129,7 @@
|
|||||||
// start connection
|
// start connection
|
||||||
var self = this;
|
var self = this;
|
||||||
this.socket = new WebSocket("wss://" + window.location.host + "/mstsc/relay.ashx");
|
this.socket = new WebSocket("wss://" + window.location.host + "/mstsc/relay.ashx");
|
||||||
|
this.socket.binaryType = 'arraybuffer';
|
||||||
this.socket.onopen = function () {
|
this.socket.onopen = function () {
|
||||||
console.log("WS-OPEN");
|
console.log("WS-OPEN");
|
||||||
self.socket.send(JSON.stringify(['infos', {
|
self.socket.send(JSON.stringify(['infos', {
|
||||||
@ -145,6 +146,8 @@
|
|||||||
}]));
|
}]));
|
||||||
};
|
};
|
||||||
this.socket.onmessage = function (evt) {
|
this.socket.onmessage = function (evt) {
|
||||||
|
if (typeof evt.data == 'string') {
|
||||||
|
// This is a JSON text string, parse it.
|
||||||
var msg = JSON.parse(evt.data);
|
var msg = JSON.parse(evt.data);
|
||||||
switch (msg[0]) {
|
switch (msg[0]) {
|
||||||
case 'rdp-connect': {
|
case 'rdp-connect': {
|
||||||
@ -153,8 +156,10 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'rdp-bitmap': {
|
case 'rdp-bitmap': {
|
||||||
|
if (self.bitmapData == null) break;
|
||||||
var bitmap = msg[1];
|
var bitmap = msg[1];
|
||||||
bitmap.data = new Uint8Array(bitmap.data.data).buffer;
|
bitmap.data = self.bitmapData; // Use the binary data that was sent earlier.
|
||||||
|
delete self.bitmapData;
|
||||||
//console.log('[mstsc.js] bitmap update bpp : ' + bitmap.bitsPerPixel);
|
//console.log('[mstsc.js] bitmap update bpp : ' + bitmap.bitsPerPixel);
|
||||||
self.render.update(bitmap);
|
self.render.update(bitmap);
|
||||||
break;
|
break;
|
||||||
@ -173,6 +178,10 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// This is binary bitmap data, store it.
|
||||||
|
self.bitmapData = evt.data;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
this.socket.onclose = function () {
|
this.socket.onclose = function () {
|
||||||
console.log("WS-CLOSE");
|
console.log("WS-CLOSE");
|
||||||
|
Loading…
Reference in New Issue
Block a user