Ideas are needed. Adding Javascript + XPCOM + C ++

So, inside Firefox there is WebRTC, and there is a convenient class for creating RTC connectivity called RTCPeerConnection, which can be created and used from a JavaScript application. You can find a worthy example at [1] . And here I am with my custom transport (if you are interested - [2] ) I would like to use it for RTC communication. In short, I need to "substitute" the transport level of the WebRTC engine with my custom transport, providing the user with the same RTCPeerConnection-like JavaScript interface. And preferably, it should not look like a custom build of Firefox (without patches). Therefore, I came up with the idea of ​​an extension that will be written in C ++ (since it should be connected to the WebRTC library and my user transport library) and somehow display its interface in Javascript. And I found XPCOM, which I thought could provide me with this. Therefore, I began to struggle with outdated and hyped information on this topic, and after 3 days of struggle, the created addition finally ended. Unfortunately, I cannot access it from Javascript because the Javascript error is "Components.classes is undefined". And it seems that there is no way to access it at all. Or I'm wrong?

Here is the 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 displayed using the XPCOM Viewer application , and the code above I can execute in the console, and a blank page is open in Firefox.

With all this in mind, I would like to ask Firefox experts about possible approaches that I can take to realize my idea. Thank you in advance

1 https://apprtc.appspot.com/

2 http://named-data.net

0
source share
1 answer

Finally, I figured out one possible solution for this and described it in post

+2
source

All Articles