fix webrtc viewonly mode #6792
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Feb 19, 2025 at 14:03 UTC
f2681de87d44bd119cebac0f223b6bf45648164b
1 file changed
+8
-1
agents/meshcore.js
+8
-1
@@ -3747,7 +3747,14 @@ function onTunnelControlData(data, ws) {
3747
{ // Desktop
3748
// Switch the user input from websocket to webrtc at this point.
3749
ws.unpipe(ws.httprequest.desktop.kvm);
3750
- try { ws.webrtc.rtcchannel.pipe(ws.httprequest.desktop.kvm, { dataTypeSkip: 1, end: false }); } catch (ex) { sendConsoleText('EX2'); } // 0 = Binary, 1 = Text.
3750
+ if ((ws.httprequest.desktopviewonly != true) && ((ws.httprequest.rights == 0xFFFFFFFF) || (((ws.httprequest.rights & MESHRIGHT_REMOTECONTROL) != 0) && ((ws.httprequest.rights & MESHRIGHT_REMOTEVIEW) == 0)))) {
3751
+ // If we have remote control rights, pipe the KVM input
3752
+ try { ws.webrtc.rtcchannel.pipe(ws.httprequest.desktop.kvm, { dataTypeSkip: 1, end: false }); } catch (ex) { sendConsoleText('EX2'); } // 0 = Binary, 1 = Text.
3753
+ } else {
3754
+ // We need to only pipe non-mouse & non-keyboard inputs.
3755
+ // sendConsoleText('Warning: No Remote Desktop Input Rights.');
3756
+ // TODO!!!
3757
+ }
3758
ws.resume(); // Resume the websocket to keep receiving control data
3759
}
3760
ws.write('{\"ctrlChannel\":\"102938\",\"type\":\"webrtc2\"}'); // Indicates we will no longer get any data on websocket, switching to WebRTC at this point.