简体   繁体   English

与节点一起使用NPAPI插件

[英]use NPAPI plugin with node

I am making a node app which utilizes a npapi plugin. 我正在制作一个使用npapi插件的节点应用程序。 basically I am trying to make it so if the device or browser that connects to the server does not support the plugin it will fall back to the server. 基本上,我正在尝试这样做,因此,如果连接到服务器的设备或浏览器不支持插件,它将退回到服务器。 currently I have a work around like that works however it requires opening a new window on the host computer whenever a request is sent 当前我有一个类似的解决方法,但是无论何时发送请求,它都需要在主机上打开一个新窗口

(workaround route) (解决方法)

var open = require('open');
var jobs = [];
router.get('/nsjob', function(req, res, next){
    var job = {
            id:(jobs.length > 0) ? jobs[jobs.length - 1].index + 1:0,
            xml://xml,
            params://params,
            callback:function(err, data){
                if(err)
                  return next(err);
                res.send(data);
            }
        };
    open('http://localhost:3000/handleJob/' + job.index);
});
router.get('/handleJob/:id', function(req, res){
    var job;
    for(var i in jobs){
        if(jobs[i].index === req.params.id){
            job = jobs[i];
            break;
        }
    }
    res.render('hjob', job')
});
router.post('/completedJob/:id', function(req, res){
    var job;
    for(var i in jobs){
        if(jobs[i].index === req.params.id){
            job = jobs[i];
            break;
        }
    }
    if(req.body)
       job.callback(req.body.err, req.body.data);
    else
       job.callback(null, null);
    res.end();
});

this works all well and good but seems like a very bad way to go about it however I need this fallback option but it makes it almost impossible to use the host computer while mobile devices are running on the server. 这一切都很好,但看起来似乎很糟糕,但是我需要此后备选项,但是这使得在服务器上运行移动设备时几乎无法使用主机。 if I could load NPAPI plugins to node I could modify the api to not use dom and essentially avoid opening a window on the host computer. 如果我可以将NPAPI插件加载到节点,则可以将api修改为不使用dom,并且基本上避免在主机上打开窗口。 however I cannot find a way to do this in node NOT NODE-WEBKIT (until it can be shipped to mobile it is pretty much useless in this case as this is primarily used by mobile users. 但是我找不到在节点NOT NODE-WEBKIT中执行此操作的方法(直到可以将其运送到移动设备为止,在这种情况下几乎没有用,因为它主要由移动用户使用。

You could hypothetically write a Node module which would load an NPAPI plugin, but it would be very difficult. 假设您可以编写一个可以加载NPAPI插件的Node模块,但这将非常困难。 There is definitely not any turnkey solution for this. 绝对没有任何交钥匙解决方案。

FireBreath 2.0 will support a new protocol that could probably be used to do this, but it's still in early planning stages. FireBreath 2.0将支持可能用于执行此操作的新协议,但它仍处于早期计划阶段。 I don't expect any releases for at least a month or two. 我预计至少一两个月不会发布任何版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM