From 28d02ff9802e07493cdd40ec6c406698f251cb42 Mon Sep 17 00:00:00 2001 From: Suwings Date: Fri, 11 Feb 2022 16:39:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routers/stream_router.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/routers/stream_router.ts b/src/routers/stream_router.ts index d7917dc..79648a8 100644 --- a/src/routers/stream_router.ts +++ b/src/routers/stream_router.ts @@ -25,6 +25,7 @@ import { missionPassport } from "../service/mission_passport"; import InstanceSubsystem from "../service/system_instance"; import logger from "../service/log"; import SendCommand from "../entity/commands/cmd"; +import SendInput from "../entity/commands/input"; // 权限认证中间件 routerApp.use(async (event, ctx, data, next) => { @@ -95,7 +96,7 @@ routerApp.on("stream/detail", async (ctx) => { } }); -// 执行命令 +// 执行命令,适用于普通进程的行式交互输入输出流 routerApp.on("stream/command", async (ctx, data) => { try { const command = data.command; @@ -107,15 +108,13 @@ routerApp.on("stream/command", async (ctx, data) => { } }); -// 处理终端输入 +// 处理终端输入,适用于伪终端的直连输入输出流。 routerApp.on("stream/input", async (ctx, data) => { try { const input = data.input; const instanceUuid = ctx.session.stream.instanceUuid; const instance = InstanceSubsystem.getInstance(instanceUuid); - // 数据流命令,采用更高效率的方式。 - // await instance.exec(new SendInput(input)); - instance.process.write(input); + await instance.exec(new SendInput(input)); } catch (error) { protocol.responseError(ctx, error); }