Node.js command line app, wrtc

236 views
Skip to first unread message

Mike Remski

unread,
Jun 4, 2021, 2:37:49 PM6/4/21
to js...@googlegroups.com
First, thanks in advance for any hints. Relatively newcomer to JS /node.js
so feel free to tell me I'm missing something simple.

Working on a node.js app, that will be run from the command line, not
within a browser, basically "node blah.js".
I'm trying to use wrtc (node-webrtc) for the WebRTC bits, I've managed to
get past the checks on if (!window.RTCPeerConnection) but I'm getting
failures in RTCSession.connec() when it tries to:

this._connection = new RTCPeerConnection(pcConfig, rtcConstraints);
giving this:
ReferenceError: RTCPeerConnection is not defined

I've got:

const wrtc = require('wrtc');
const RTCPeerConnection = wrtc.RTCPeerConnection;
const RTCIceCandidate = wrtc.RTCIceCandidate;
const RTCSessionDescription = wrtc.RTCSessionDescription;
const MediaStream = wrtc.MediaStream;
const MediaStreamTrack = wrtc.MediaStreamTrack;
const getUserMedia = wrtc.getUserMedia;
const mediaDevices = wrtc.mediaDevices;

before
const JsSIP = require('jssip');

my understanding (misunderstanding?) is that RTCPeerConnection should be
visible to JsSIP, but obviously not.

Any hints/pointers would be appreciated, even if it's search terms I can as
Google about.

Thanks

Mike Remski

unread,
Jun 7, 2021, 11:16:49 AM6/7/21
to JsSIP


Well, I managed to figure something out.   A closer reading of node js documentation led me to "global"
so adding lines like:
global.RTCPeerConnection = wrtc.RTCPeerConnection seem to work.

Yes, I realize it is basically not knowing the language well enough.
Reply all
Reply to author
Forward
0 new messages