Reputation: 19989
I've made a simple calling application using WebRTC. I've established an connection and I can now call from one browser to another.
One thing I still can't figure out and can't find in the WebRTC standard is ... How can I reject an call offer.
If I get an offer from the caller I was thinking about following
if(msg.type == 'offer') {
if(confirm(msg.sender+" is calling you ...")) {
$.calling.calleePeer.setRemoteDescription(new RTCSessionDescription(msg));
$.calling.calleePeer.addStream($.calling.localstream);
$.calling.calleePeer.createAnswer($.calling.setLocalCalleeAndSendDescription, null, $.calling.mediaConstraints);
} else {
// TODO What to do here in order to reject the offer?
}
}
Now everything works when I accept the offer, but how I can let the caller know that I'm not interesting in the call right now? I guess there is some solution build into the standard.
Upvotes: 3
Views: 2195
Reputation: 4434
In WebRTC, the signalling protocol is whatever you define, so the application should send a command to the other party informing that the offer was rejected by the user.
When you do this, you must close the PeerConnection Objects on both parties, and the browser will stop waiting or trying to establish connection.
if(msg.type == 'offer') {
if(confirm(msg.sender+" is calling you ...")) {
$.calling.calleePeer.setRemoteDescription(new RTCSessionDescription(msg));
$.calling.calleePeer.addStream($.calling.localstream);
$.calling.calleePeer.createAnswer($.calling.setLocalCalleeAndSendDescription, null, $.calling.mediaConstraints);
} else {
$.calling.calleePeer.close();
// Send a command to the other party (i.e. a response to the invitation) rejecting the offer.
}
}
The client that started the process should do the same, when receiving the rejection.
// I suppose you have something like this.
$.calling.callerPeer.close();
Upvotes: 2