script.ts 466 B

12345678910111213141516171819
  1. import {Command, Session} from "../session";
  2. import {CommandHandler} from "./base";
  3. export class ScriptHandler implements CommandHandler {
  4. session: Session;
  5. accept_command = ['run_script'];
  6. constructor(session: Session) {
  7. this.session = session;
  8. }
  9. handle_message(msg: Command) {
  10. let script = msg.spec as string;
  11. const script_func = new Function('WebIOCurrentTaskID', script);
  12. script_func(msg.task_id);
  13. }
  14. }