Skip to content

Commit

Permalink
Improvements to 2xx retransmission behaviour
Browse files Browse the repository at this point in the history
Fixes #131
  • Loading branch information
Gavin Llewellyn committed Jul 10, 2013
1 parent 3fc4efa commit f4a29e9
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/RTCSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

/**
Expand Down

0 comments on commit f4a29e9

Please sign in to comment.