This commit is contained in:
Ylian Saint-Hilaire 2022-06-29 14:44:21 -07:00
commit fe91709a44

View File

@ -1365,13 +1365,18 @@ function handleServerCommand(data) {
} }
case 'setclip': { case 'setclip': {
// Set the load clipboard to a user value // Set the load clipboard to a user value
if (typeof data.data == 'string') { if (typeof data.data == 'string')
{
MeshServerLogEx(22, [data.data.length], "Setting clipboard content, " + data.data.length + " byte(s)", data); MeshServerLogEx(22, [data.data.length], "Setting clipboard content, " + data.data.length + " byte(s)", data);
if (require('MeshAgent').isService) { if (require('MeshAgent').isService)
if (process.platform != 'win32') { {
if (process.platform != 'win32')
{
require('clipboard').dispatchWrite(data.data); require('clipboard').dispatchWrite(data.data);
mesh.SendCommand({ action: 'msg', type: 'setclip', sessionid: data.sessionid, success: true });
} }
else { else
{
var clipargs = data.data; var clipargs = data.data;
var uid = require('user-sessions').consoleUid(); var uid = require('user-sessions').consoleUid();
var user = require('user-sessions').getUsername(uid); var user = require('user-sessions').getUsername(uid);
@ -1381,20 +1386,24 @@ function handleServerCommand(data) {
this._dispatcher = require('win-dispatcher').dispatch({ user: user, modules: [{ name: 'clip-dispatch', script: "module.exports = { dispatch: function dispatch(val) { require('clipboard')(val); process.exit(); } };" }], launch: { module: 'clip-dispatch', method: 'dispatch', args: [clipargs] } }); this._dispatcher = require('win-dispatcher').dispatch({ user: user, modules: [{ name: 'clip-dispatch', script: "module.exports = { dispatch: function dispatch(val) { require('clipboard')(val); process.exit(); } };" }], launch: { module: 'clip-dispatch', method: 'dispatch', args: [clipargs] } });
this._dispatcher.parent = this; this._dispatcher.parent = this;
//require('events').setFinalizerMetadata.call(this._dispatcher, 'clip-dispatch'); //require('events').setFinalizerMetadata.call(this._dispatcher, 'clip-dispatch');
this._dispatcher.on('connection', function (c) { this._dispatcher.on('connection', function (c)
{
this._c = c; this._c = c;
this._c.root = this.parent; this._c.root = this.parent;
this._c.on('end', function () { this._c.on('end', function ()
{
this.root._dispatcher = null; this.root._dispatcher = null;
this.root = null; this.root = null;
mesh.SendCommand({ action: 'msg', type: 'setclip', sessionid: data.sessionid, success: true });
}); });
}); });
} }
} }
else { else
{
require("clipboard")(data.data); require("clipboard")(data.data);
mesh.SendCommand({ action: 'msg', type: 'setclip', sessionid: data.sessionid, success: true });
} // Set the clipboard } // Set the clipboard
mesh.SendCommand({ action: 'msg', type: 'setclip', sessionid: data.sessionid, success: true });
} }
break; break;
} }