I am working on webrtc based Audio/Video conferencing app. For that, I have created a frontend in Angular 11 and the Backend node(express server). So I have created this app in using vanilla JS, HTML, CSS and it worked. But when I tried to convert the frontend into Angular app that where the problem comes.
Working of the app goes like this, first I create the room and I will get a roomId which I send to another person and he uses that roomId to join the room for a chat.
When another person joins the room then onRoomJoined() gets executed on my side.
async onRoomJoined(data) {
await this.setUpConnection(data['client-id'], data['client-name']);
this.socket.emit('send-metadata', { 'room-id': this.roomId, 'client-name': this.clientName,
'client-id': this.clientId, 'peer-id': data['client-id'] });
}
Now this function further calls setUpConnection() function which is as follows,
async setUpConnection(peerId, peerName, initiateCall = false){
const videoElement = this.getVideoElement(peerId, 0, peerName);
videoElement.autoplay = true;
videoElement.playsInline = true;
this.peerConnections[peerId] = { 'peer-name': peerName, 'pc': new RTCPeerConnection(iceServers) };
this.peerConnections[peerId].pc.ontrack = (track) => { this.setRemoteStream(track, peerId); };
this.addLocalStreamTracks(peerId);
this.peerConnections[peerId].pc.onicecandidate = (iceCandidate) => { this.gatherIceCandidates(iceCandidate, peerId); };
this.peerConnections[peerId].pc.oniceconnectionstatechange = (event) => { this.checkPeerDisconnection(event, peerId); };
if (initiateCall === true) {
await this.createOffer(peerId);
}
}
Following is the error I am getting in the browser console on my side(room creator),
ERROR Error: Uncaught (in promise): TypeError: this.setUpConnection is not a function
TypeError: this.setUpConnection is not a function
at Socket.<anonymous> (home.component.ts:440)
at Generator.next (<anonymous>)
at tslib.es6.js:76
at new ZoneAwarePromise (zone-evergreen.js:960)
at __awaiter (tslib.es6.js:72)
at Socket.onRoomJoined (home.component.ts:438)
at Socket.push.cpc2.Emitter.emit (index.js:145)
at Socket.emit (typed-events.js:46)
at Socket.emitEvent (socket.js:263)
at Socket.onevent (socket.js:250)
at resolvePromise (zone-evergreen.js:798)
at new ZoneAwarePromise (zone-evergreen.js:963)
at __awaiter (tslib.es6.js:72)
at Socket.onRoomJoined (home.component.ts:438)
at Socket.push.cpc2.Emitter.emit (index.js:145)
at Socket.emit (typed-events.js:46)
at Socket.emitEvent (socket.js:263)
at Socket.onevent (socket.js:250)
at Socket.onpacket (socket.js:214)
at Manager.push.cpc2.Emitter.emit (index.js:145)
Here Both of above functions onRoomJoined() and setUpConnection() are there in home.component.ts file. Still I am getting the TypeError: this.setUpConnection is not a function.
How this is possible?
Any Help is appreciated, Thanks!
thismay not be what you think it is..