add set remote clipboard to web-rdp #4133
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Jan 14, 2024 at 17:42 UTC
9986567cf03caf4040a162acb14b7128daa77198
1 file changed
+16
public/mstsc/client.js
+16
@@ -18,6 +18,7 @@
18
*/
19
/*
20
* added get clipboard from remote RDP - Simon Smith 2024
21
+ * added set clipboard to remote RDP - Simon Smith 2024
22
*/
23
24
(function() {
@@ -176,6 +177,19 @@
177
options: options,
178
locale: Mstsc.locale()
179
}]));
180
+ self.prevClipboardText = null;
181
+ self.clipboardReadTimer = setInterval(function(){
182
+ if(navigator.clipboard.readText != null){
183
+ navigator.clipboard.readText()
184
+ .then(function(data){
185
+ if(data != self.prevClipboard){
186
+ self.prevClipboard = data;
187
+ if (self.socket) { self.socket.send(JSON.stringify(['clipboard', data])); }
188
+ }
189
+ })
190
+ .catch(function(){ });
191
+ }
192
+ }, 1000);
193
};
194
this.socket.onmessage = function (evt) {
195
if (typeof evt.data == 'string') {
@@ -226,6 +240,8 @@
240
this.socket.onclose = function () {
241
//console.log("WS-CLOSE");
242
self.activeSession = false;
243
+ clearInterval(self.clipboardReadTimer);
244
+ self.prevClipboardText = null;
245
next(null);
246
};
247
}