Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions lib/src/rtc_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3281,19 +3281,20 @@ class RTCSession extends EventManager implements Owner {

// I'm the refresher.
if (_sessionTimers.refresher) {
_sessionTimers.timer = setTimeout(() {
if (_state == RtcSessionState.terminated) {
return;
}

logger.d('runSessionTimer() | sending session refresh request');

if (_sessionTimers.refreshMethod == SipMethod.UPDATE) {
_sendUpdate();
} else {
_sendReinvite();
}
}, expires! * 500); // Half the given interval (as the RFC states).
final int delayMs = expires! * 500;
_sessionTimers.timer = Timer.periodic(
Duration(milliseconds: delayMs),
(_) {
if (_state == RtcSessionState.terminated) return;
logger.d(
'runSessionTimer() | sending session refresh request with expires=$expires, delayMs=$delayMs');
if (_sessionTimers.refreshMethod == SipMethod.UPDATE) {
_sendUpdate();
} else {
_sendReinvite();
}
},
);
}
// I'm not the refresher.
else {
Expand Down
13 changes: 11 additions & 2 deletions lib/src/sip_ua_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class SIPUAHelper extends EventManager {
_settings.session_timers = uaSettings.sessionTimers;
_settings.ice_gathering_timeout = uaSettings.iceGatheringTimeout;
_settings.session_timers_refresh_method =
uaSettings.sessionTimersRefreshMethod;
uaSettings.sessionTimersRefreshMethodEnum;
_settings.instance_id = uaSettings.instanceId;
_settings.registrar_server = uaSettings.registrarServer;
_settings.contact_uri = uaSettings.contact_uri != null
Expand Down Expand Up @@ -921,5 +921,14 @@ class UaSettings {
/// Controls which kind of messages are to be sent to keep a SIP session
/// alive.
/// Defaults to "UPDATE"
DartSIP_C.SipMethod sessionTimersRefreshMethod = DartSIP_C.SipMethod.UPDATE;
String sessionTimersRefreshMethod = 'UPDATE';
DartSIP_C.SipMethod get sessionTimersRefreshMethodEnum {
switch (sessionTimersRefreshMethod.toUpperCase()) {
case 'INVITE':
return DartSIP_C.SipMethod.INVITE;
case 'UPDATE':
default:
return DartSIP_C.SipMethod.UPDATE;
}
}
}