需要的想法。 Javascript + XPCOM + C ++附加组件 [英] Ideas needed. Javascript+XPCOM+C++ add-on

查看:208
本文介绍了需要的想法。 Javascript + XPCOM + C ++附加组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在Firefox内部有一个WebRTC,并且有一个方便的RTC通信类,称为RTCPeerConnection,可以从JavaScript应用程序实例化和使用。你可以在 [1] 找到一些体面的例子。
在这里,我与我的自定义运输(如果你有兴趣 - [2] )想将其用于RTC通信。简而言之,我需要通过自定义传输替换WebRTC引擎的传输层,同时为用户提供相同的RTCPeerConnection-like JavaScript接口。最好,它不应该看起来像Firefox的自定义构建(没有补丁)。
所以我想出了扩展的想法,它将用C ++编写(因为它需要与WebRTC库和我的自定义传输库链接),并以某种方式将其接口暴露给Javascript。而且我发现XPCOM可以为我提供这个功能。
因此,我已经开始与这个主题过时和稀疏的信息斗争,并经过3天的挣扎终于结束了与builded附加。不幸的是,由于Javascript的Components.classes is undefined错误,我无法从Javascript访问它。而且似乎根本无法访问它。或者我错了?



这里是Javascript:

  function check()
{
console.debug(checking ...);

const {Cc,Ci,Cu} = require(chrome);
var rtc = Components.classes [@ named-data.net/ndnrtc;1]。createInstance();
rtc = rtc.QueryInterface(Ci.ndINrtc);

console.debug(rtc:+ rtc);

$ / code>

我的组件是可通过XPCOM查看器上面的代码可以在控制台执行,而在Firefox中打开空白页



我想请问Firefox专家,为了实现我的想法,我可以采取哪些可行的方法。
预先感谢您



1 https://apprtc.appspot.com/



2 http: //named-data.net

解决方案

最后,我想出了一个可能的解决方案,它在我的文章


So, there is a WebRTC inside Firefox and there is a convenient class for making RTC communication possible called RTCPeerConnection which can be instantiated and used from the JavaScript app. You can find some decent example of it on [1]. And here am I with my custom transport (if you're interested - [2]) would like to use it for RTC communication. Briefly, I need to "substitute" the transport layer of WebRTC engine by my custom transport while providing the same RTCPeerConnection-like JavaScript interface for the user. And preferably, it should not look like custom build of Firefox (no patches). So I've come up with the idea of extension, which will be written in C++ (since it need to be linked with WebRTC library and my custom transport library) and somehow will expose its interface to Javascript. And I've found XPCOM which, as I thought, can provide me this. So I've started to fight with out-dated and sparsed info on this topic and after 3 days of struggling finally ended up with builded add-on. Unfortunately, I can't access it from Javascript, because of Javascript's "Components.classes is undefined" error. And it seems that there is no way to access it at all. Or I'm wrong on that?

Here is Javascript:

function check()
{
console.debug("checking...");   

const {Cc,Ci,Cu} = require("chrome");
var rtc = Components.classes["@named-data.net/ndnrtc;1"].createInstance();
rtc = rtc.QueryInterface(Ci.ndINrtc);   

console.debug("rtc: "+rtc);
}

My component is visible with XPCOM Viewer addon and the code above I can execute in the console while empty page is open in Firefox.

Given all that, I would like to ask Firefox experts regarding possible approaches which I can take in order to implement my idea. Thank you in advance

1 https://apprtc.appspot.com/

2 http://named-data.net

解决方案

Finally, I've figured out one possible solution for that and describe it in my post

这篇关于需要的想法。 Javascript + XPCOM + C ++附加组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆