notify method
Implementation
void notify(int? code, [String? reason]) {
logger.debug('notify()');
if (_active == false) {
return;
}
reason = reason ?? DartSIP_C.REASON_PHRASE[code!] ?? '';
String state;
if (code! >= 200) {
state = 'terminated;reason=noresource';
} else {
state = 'active;expires=$_expires';
}
EventManager handlers = EventManager();
handlers.on(EventOnErrorResponse(), (EventOnErrorResponse event) {
// If a negative response is received, subscription is canceled.
_active = false;
});
// Put this in a try/catch block.
_session.sendRequest(SipMethod.NOTIFY, <String, dynamic>{
'extraHeaders': <String>[
'Event: ${C.event_type};id=$_id',
'Subscription-State: $state',
'Content-Type: ${C.body_type}'
],
'body': 'SIP/2.0 $code $reason',
'eventHandlers': handlers
});
}