Skip to content
Permalink
Browse files

Improvements to 2xx retransmission behaviour

Fixes #131
  • Loading branch information
gavllew committed Jul 10, 2013
1 parent 3fc4efa commit f4a29e92f577aee25b5236fa0053642953e5c0b4
Showing with 16 additions and 17 deletions.
  1. +16 −17 src/RTCSession.js
@@ -197,34 +197,33 @@ RTCSession.prototype.answer = function(options) {
var
// run for reply success callback
replySucceeded = function() {
var timeout = JsSIP.Timers.T1;

self.status = C.STATUS_WAITING_FOR_ACK;

/**
* RFC3261 13.3.1.4
* Response retransmissions cannot be accomplished by transaction layer
* since it is destroyed when receiving the first 2xx answer
*/
self.timers.invite2xxTimer = window.setTimeout(function invite2xxRetransmission(retransmissions) {
retransmissions = retransmissions || 1;

var timeout = JsSIP.Timers.T1 * (Math.pow(2, retransmissions));

if((retransmissions * JsSIP.Timers.T1) <= JsSIP.Timers.T2) {
retransmissions += 1;
self.timers.invite2xxTimer = window.setTimeout(function invite2xxRetransmission() {
if (self.status !== C.STATUS_WAITING_FOR_ACK) {
return;
}

request.reply(200, null, ['Contact: '+ self.contact], body);
request.reply(200, null, ['Contact: '+ self.contact], body);

self.timers.invite2xxTimer = window.setTimeout(
function() {
invite2xxRetransmission(retransmissions);
},
timeout
);
} else {
window.clearTimeout(self.timers.invite2xxTimer);
if (timeout < JsSIP.Timers.T2) {
timeout = timeout * 2;
if (timeout > JsSIP.Timers.T2) {
timeout = JsSIP.Timers.T2;
}
}
self.timers.invite2xxTimer = window.setTimeout(
invite2xxRetransmission, timeout
);
},
JsSIP.Timers.T1
timeout
);

/**

0 comments on commit f4a29e9

Please sign in to comment.
You can’t perform that action at this time.