Add stop method for web app

This commit is contained in:
Rafostar
2020-12-15 11:51:25 +01:00
parent ea67e1e620
commit 062a307613

View File

@@ -12,25 +12,52 @@ class ClapperWebApp extends Gio.SubprocessLauncher
const flags = Gio.SubprocessFlags.STDOUT_SILENCE const flags = Gio.SubprocessFlags.STDOUT_SILENCE
| Gio.SubprocessFlags.STDERR_SILENCE; | Gio.SubprocessFlags.STDERR_SILENCE;
super._init(flags); super._init({ flags });
this.remoteApp = null;
this.isRemoteClosing = false;
this.setenv('GDK_BACKEND', 'broadway', true);
} }
startRemoteApp() startRemoteApp()
{ {
this.setenv('GDK_BACKEND', 'broadway', true); if(this.remoteApp)
this.setenv('BROADWAY_DISPLAY', '6', true); return;
this.remoteApp = this.spawnv(Misc.appId); this.remoteApp = this.spawnv([Misc.appId + 'Remote']);
this.remoteApp.wait_async(null, this._onRemoteClosed.bind(this)); this.remoteApp.wait_async(null, this._onRemoteClosed.bind(this));
debug('remote app started'); debug('remote app started');
} }
_onRemoteClosed(remoteApp, res) stopRemoteApp()
{ {
debug('remote app closed'); if(!this.remoteApp || this.isRemoteClosing)
return;
this.setenv('GDK_BACKEND', '', true); this.isRemoteClosing = true;
this.setenv('BROADWAY_DISPLAY', '', true); this.remoteApp.force_exit();
debug('send stop signal to remote app');
}
_onRemoteClosed(proc, result)
{
let hadError;
try {
hadError = proc.wait_finish(result);
}
catch(err) {
debug(err);
}
this.remoteApp = null;
if(hadError)
debug('remote app exited with error');
debug('remote app closed');
} }
}); });