mirror of
https://github.com/koush/scrypted.git
synced 2026-08-13 08:30:37 +01:00
Merge branch 'main' of github.com:koush/scrypted
This commit is contained in:
@@ -37,16 +37,22 @@ export default {
|
||||
const rootLocation = `${window.location.protocol}//${window.location.host}`;
|
||||
this.socket = eio(rootLocation, options);
|
||||
|
||||
this.socket.send(JSON.stringify({ dim: { cols: term.cols, rows: term.rows } }));
|
||||
|
||||
this.socket.on("message", (data) => {
|
||||
term.write(new Uint8Array(Buffer.from(data)));
|
||||
term.write(new Uint8Array(Buffer.from(JSON.parse(data).data)));
|
||||
});
|
||||
|
||||
term.onData((data) => {
|
||||
this.socket.send(data);
|
||||
this.socket.send(JSON.stringify({ data }));
|
||||
});
|
||||
|
||||
term.on('resize', dim => {
|
||||
this.socket.send(JSON.stringify({ dim }));
|
||||
});
|
||||
|
||||
term.onBinary((data) => {
|
||||
this.socket.send(data);
|
||||
this.socket.send(JSON.stringify({ data }));
|
||||
});
|
||||
},
|
||||
destroyed() {
|
||||
|
||||
@@ -119,8 +119,15 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
|
||||
const spawn = require('node-pty-prebuilt-multiarch').spawn as typeof ptySpawn;
|
||||
const cp = spawn(process.env.SHELL, [], {
|
||||
});
|
||||
cp.onData(data => connection.send(data));
|
||||
connection.on('message', message => cp.write(message.toString()));
|
||||
cp.onData(data => connection.send(JSON.stringify({data})));
|
||||
connection.on('message', message => {
|
||||
const parsed = JSON.parse(message.toString());
|
||||
if (parsed.data) {
|
||||
cp.write(parsed.data);
|
||||
} else if (parsed.dim) {
|
||||
cp.resize(parsed.dim.cols, parsed.dim.rows);
|
||||
}
|
||||
});
|
||||
connection.on('close', () => cp.kill());
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user