Skip to content

Commit 1dec98c

Browse files
committed
fix _runSessionTimer() to periodically send the sip refresh request
1 parent 07c19bb commit 1dec98c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/src/rtc_session.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3281,19 +3281,19 @@ class RTCSession extends EventManager implements Owner {
32813281

32823282
// I'm the refresher.
32833283
if (_sessionTimers.refresher) {
3284-
_sessionTimers.timer = setTimeout(() {
3285-
if (_state == RtcSessionState.terminated) {
3286-
return;
3287-
}
3288-
3289-
logger.d('runSessionTimer() | sending session refresh request');
3290-
3291-
if (_sessionTimers.refreshMethod == SipMethod.UPDATE) {
3292-
_sendUpdate();
3293-
} else {
3294-
_sendReinvite();
3295-
}
3296-
}, expires! * 500); // Half the given interval (as the RFC states).
3284+
final int delayMs = expires! * 500;
3285+
_sessionTimers.timer = Timer.periodic(
3286+
Duration(milliseconds: delayMs),
3287+
(_) {
3288+
if (_state == RtcSessionState.terminated) return;
3289+
logger.d('runSessionTimer() | sending session refresh request with expires=$expires, delayMs=$delayMs');
3290+
if (_sessionTimers.refreshMethod == SipMethod.UPDATE) {
3291+
_sendUpdate();
3292+
} else {
3293+
_sendReinvite();
3294+
}
3295+
},
3296+
);
32973297
}
32983298
// I'm not the refresher.
32993299
else {

0 commit comments

Comments
 (0)