Skip to content

Instantly share code, notes, and snippets.

@Vatsalya-singhi
Created August 3, 2020 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vatsalya-singhi/6cb9e2277318789862b47efbf903ad6e to your computer and use it in GitHub Desktop.
Save Vatsalya-singhi/6cb9e2277318789862b47efbf903ad6e to your computer and use it in GitHub Desktop.
public createAndSendOffer(id: string) {
this.peerConnections[id]
.createOffer(this.offerOptions)
.then(async (offer: RTCSessionDescriptionInit) => {
if (this.peerConnections[id].signalingState != "stable") {
console.log("-- The connection isn't stable yet; postponing...")
return;
}
this.peerConnections[id].setLocalDescription(offer).then(() => {
console.log('sending Offer');
this.socket.sendOffer(id, this.peerConnections[id].localDescription);
}).catch((err) => {
console.log('local desc was not set & offer not sent');
});
}, (err) => {
console.log('offer not created=>', err);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment