mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Fix KVM clean up on WebRTC disconnect in meshcore.js.
This commit is contained in:
parent
8b60090e33
commit
9230a4508a
12 changed files with 38 additions and 19 deletions
|
@ -1,3 +1,4 @@
|
|||
@ECHO OFF
|
||||
MD modules_meshcmd_min
|
||||
MD modules_meshcore_min
|
||||
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" compressalljs "modules_meshcore" "modules_meshcore_min"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
@ECHO OFF
|
||||
DEL meshcmd.min.js
|
||||
DEL meshcore.min.js
|
||||
DEL modules_meshcmd_min\*.min.js
|
||||
|
|
2
agents/meshcmd.min.js
vendored
2
agents/meshcmd.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -701,8 +701,17 @@ function createMeshCore(agent) {
|
|||
|
||||
this.end = function () {
|
||||
--this.desktop.kvm.connectionCount;
|
||||
|
||||
// Unpipe the web socket
|
||||
this.unpipe(this.httprequest.desktop.kvm);
|
||||
this.httprequest.desktop.kvm.unpipe(this);
|
||||
|
||||
// Unpipe the WebRTC channel if needed (This will also be done when the WebRTC channel ends).
|
||||
if (this.rtcchannel) {
|
||||
this.rtcchannel.unpipe(this.httprequest.desktop.kvm);
|
||||
this.httprequest.desktop.kvm.unpipe(this.rtcchannel);
|
||||
}
|
||||
|
||||
if (this.desktop.kvm.connectionCount == 0) {
|
||||
// Display a toast message
|
||||
//require('toaster').Toast('MeshCentral', 'Remote Desktop Control Ended.');
|
||||
|
@ -995,7 +1004,12 @@ function createMeshCore(agent) {
|
|||
this.rtcchannel = rtcchannel;
|
||||
this.websocket.rtcchannel = rtcchannel;
|
||||
this.websocket.rtcchannel.on('data', onTunnelWebRTCControlData);
|
||||
this.websocket.rtcchannel.on('end', function () { /*sendConsoleText('Tunnel #' + this.websocket.tunnel.index + ' WebRTC data channel closed');*/ });
|
||||
this.websocket.rtcchannel.on('end', function () {
|
||||
// The WebRTC channel closed, unpipe the KVM now. This is also done when the web socket closes.
|
||||
/*sendConsoleText('Tunnel #' + this.websocket.tunnel.index + ' WebRTC data channel closed');*/
|
||||
this.unpipe(this.websocket.desktop.kvm);
|
||||
this.websocket.httprequest.desktop.kvm.unpipe(this);
|
||||
});
|
||||
this.websocket.write("{\"ctrlChannel\":\"102938\",\"type\":\"webrtc0\"}"); // Indicate we are ready for WebRTC switch-over.
|
||||
});
|
||||
var sdp = null;
|
||||
|
@ -1719,7 +1733,7 @@ function createMeshCore(agent) {
|
|||
var rtc = require('ILibWebRTC');
|
||||
webRtcDesktop.webrtc = rtc.createConnection();
|
||||
webRtcDesktop.webrtc.on('connected', function () { });
|
||||
webRtcDesktop.webrtc.on('disconnected', function () { webRtcCleanUp(); });
|
||||
webRtcDesktop.webrtc.on('disconnected', function () { obj.webRtcCleanUp(); });
|
||||
webRtcDesktop.webrtc.on('dataChannel', function (rtcchannel) {
|
||||
webRtcDesktop.rtcchannel = rtcchannel;
|
||||
webRtcDesktop.kvm = mesh.getRemoteDesktopStream();
|
||||
|
@ -1727,7 +1741,7 @@ function createMeshCore(agent) {
|
|||
webRtcDesktop.rtcchannel.on('end', function () { obj.webRtcCleanUp(); });
|
||||
webRtcDesktop.rtcchannel.on('data', function (x) { obj.kvmCtrlData(this, x); });
|
||||
webRtcDesktop.rtcchannel.pipe(webRtcDesktop.kvm, { dataTypeSkip: 1, end: false });
|
||||
//webRtcDesktop.kvm.on('end', function () { console.log('WebRTC DataChannel closed2'); webRtcCleanUp(); });
|
||||
//webRtcDesktop.kvm.on('end', function () { console.log('WebRTC DataChannel closed2'); obj.webRtcCleanUp(); });
|
||||
//webRtcDesktop.rtcchannel.on('data', function (data) { console.log('WebRTC data: ' + data); });
|
||||
});
|
||||
obj.kvmSetData(JSON.stringify({ action: 'answer', ver: 1, sdp: webRtcDesktop.webrtc.setOffer(data.sdp) }));
|
||||
|
@ -1885,7 +1899,8 @@ function createMeshCore(agent) {
|
|||
}
|
||||
}
|
||||
|
||||
obj.webRtcCleanUp = function() {
|
||||
obj.webRtcCleanUp = function () {
|
||||
sendConsoleText('webRtcCleanUp');
|
||||
if (webRtcDesktop == null) return;
|
||||
if (webRtcDesktop.rtcchannel) {
|
||||
try { webRtcDesktop.rtcchannel.close(); } catch (e) { }
|
||||
|
|
2
agents/meshcore.min.js
vendored
2
agents/meshcore.min.js
vendored
File diff suppressed because one or more lines are too long
2
agents/modules_meshcmd_min/amt-mei.min.js
vendored
2
agents/modules_meshcmd_min/amt-mei.min.js
vendored
File diff suppressed because one or more lines are too long
2
agents/modules_meshcmd_min/amt.min.js
vendored
2
agents/modules_meshcmd_min/amt.min.js
vendored
File diff suppressed because one or more lines are too long
2
agents/modules_meshcore_min/amt-mei.min.js
vendored
2
agents/modules_meshcore_min/amt-mei.min.js
vendored
File diff suppressed because one or more lines are too long
2
agents/modules_meshcore_min/amt.min.js
vendored
2
agents/modules_meshcore_min/amt.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue