【问题标题】:Worker stuck in a Sandbox?工人被困在沙箱中?
【发布时间】:2017-10-12 20:32:07
【问题描述】:

试图弄清楚为什么我可以在主线程上使用我的 rest API 登录,但不能在工作线程中登录。所有通信渠道都运行良好,我可以毫无问题地加载它。但是,当它尝试发送一些数据时,它只是挂起。

    [Embed(source="../bin/BGThread.swf", mimeType="application/octet-stream")]      
    private static var BackgroundWorker_ByteClass:Class;
    public static function get BackgroundWorker():ByteArray
    {
        return new BackgroundWorker_ByteClass();
    }

在测试脚本上:

    public function Main() 
    {
        fBCore.init("secrets", "my-firebase-id");
        trace("Init");
        //fBCore.auth.addEventListener(FBAuthEvent.LOGIN_SUCCES, hanldeFBSuccess);
        fBCore.auth.addEventListener(AuthEvent.LOGIN_SUCCES, hanldeFBSuccess);
        fBCore.auth.addEventListener(IOErrorEvent.IO_ERROR, handleIOError);

        fBCore.auth.email_login("admin@admin.admin", "password");

    }

    private function handleIOError(e:IOErrorEvent):void 
    {
        trace("IO error");
        trace(e.text); //Nothing here
    }

    private function hanldeFBSuccess(e:AuthEvent):void 
    {
        trace("Main login success.");
        trace(e.message);//Complete success.
    }

当类通过从 Main 在 init 传递的内部工作通道触发时:

原始:

    private function handleLoginClick(e:MouseEvent):void 
    {
        login_mc.buttonMode = false;
        login_mc.play();
        login_mc.removeEventListener(MouseEvent.CLICK, handleLoginClick);

        log("Logging in as " + email_mc.text_txt.text);
        commandChannel.send([BGThreadCommand.LOGIN, email_mc.text_txt.text, password_mc.text_txt.text]);
    }

工人:

                    ...
                    case BGThreadCommand.LOGIN:
                        log("Logging in with " + message[1] + "::" + message[2]); //Log goes to a progress channel and comes to the main thread reading the outputs successfully.
                        fbCore.auth.email_login(message[1], message[2]);
                        fbCore.auth.addEventListener(AuthEvent.LOGIN_SUCCES, loginSuccess); //Nothing
                        fbCore.auth.addEventListener(IOErrorEvent.IO_ERROR, handleLoginIOError); //Fires
                        break;

Auth Rest 类:https://github.com/sfxworks/FirebaseREST/blob/master/src/net/sfxworks/firebaseREST/Auth.as

这是工作人员限制还是安全沙盒问题?我有一种深刻的感觉是两者中的后者。如果是这种情况,我将如何以一种同时赋予它适当的行动权限的方式加载工作人员?

【问题讨论】:

  • 哦,这是一个的问题。无法确定,但让我引用官方手册:在后台工作程序中运行的代码中没有几个运行时 API。这些主要由与用户输入和输出机制相关的 API 或操作系统元素(如窗口和拖动)组成。 注意后台和辅助工作人员不支持本机扩展。
  • @Organis 我在研究时确实看到了这一点。我在这个线程中使用的唯一东西是 URLLoader 和 URLStream,因为这是我的 rest api 所建立的。该 api 不是 ANE,所以这就是为什么我想知道为什么它不起作用。虽然因为这两个都是异步的,但我想知道 AIR 是否阻止了工作人员这样做。
  • 好吧。工人在什么样的沙箱里?它与主应用沙箱匹配吗? help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/…

标签: multithreading actionscript-3 flash air


【解决方案1】:

完全忽略了createWorker 函数中的 giveAppPrivelages 属性。对不起 Stackoverflow。有时,当我前一天晚上睡得很少(或者在这种情况下没有睡)时,我会提出不好的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-19
    • 1970-01-01
    • 2013-05-17
    • 1970-01-01
    • 2013-04-10
    • 2017-09-14
    • 2013-03-06
    • 1970-01-01
    相关资源
    最近更新 更多