Fully interactive terminal!
This commit is contained in:
parent
7df0eea51d
commit
250509ffe1
|
@ -16,9 +16,10 @@ export class Session {
|
|||
this.run();
|
||||
ws.on("message", this.handleClientMessage);
|
||||
}
|
||||
handleClientMessage(msg) {
|
||||
handleClientMessage = (event: string) => {
|
||||
let msg: any;
|
||||
try {
|
||||
msg = JSON.parse(msg);
|
||||
msg = JSON.parse(event);
|
||||
} catch (err) {
|
||||
console.error(`failed to parse client message: ${msg}`);
|
||||
return;
|
||||
|
@ -37,8 +38,8 @@ export class Session {
|
|||
console.error(`unknown client message type: ${msg.event}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
run() {
|
||||
};
|
||||
run = () => {
|
||||
const cmdline = this.config.cmdline;
|
||||
if (this.term) {
|
||||
this.term.kill();
|
||||
|
@ -51,5 +52,5 @@ export class Session {
|
|||
this.term.on("data", (data) =>
|
||||
this.ws.send(JSON.stringify({ event: "terminalOutput", output: data }))
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -53,3 +53,7 @@ socket.addEventListener("close", (event) => {
|
|||
socket.addEventListener("onerror", (event) =>
|
||||
console.error("Connection error:", event)
|
||||
);
|
||||
|
||||
term.onData((data) =>
|
||||
socket.send(JSON.stringify({ event: "terminalInput", input: data }))
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue