Skip to content
Open
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
29 changes: 29 additions & 0 deletions lib/src/sip_ua_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ class SIPUAHelper extends EventManager {
});
});

handlers.on(EventNewInfo(), (EventNewInfo event) {
_notifyInfoListeners(event);
});

handlers.on(EventReInvite(), (EventReInvite event) {
logger.d('Reinvite received in helper, notifying listeners');
_notifyReInviteListeners(event);
Expand Down Expand Up @@ -520,6 +524,22 @@ class SIPUAHelper extends EventManager {
listener.onNewNotify(Notify(request: event.request));
}
}

void _notifyInfoListeners(EventNewInfo event) {
// Copy to prevent concurrent modification exception
List<SipUaHelperListener> listeners = _sipUaHelperListeners.toList();
final IncomingRequest? request =
event.request is IncomingRequest ? event.request as IncomingRequest : null;
final SipInfo info = SipInfo(
contentType: event.info?.contentType ?? request?.getHeader('content-type'),
body: event.info?.body ?? request?.body,
request: request,
originator: event.originator,
);
for (SipUaHelperListener listener in listeners) {
listener.onNewInfo(info);
}
}
}

enum CallStateEnum {
Expand Down Expand Up @@ -775,13 +795,22 @@ abstract class SipUaHelperListener {
void onNewMessage(SIPMessageRequest msg);
void onNewNotify(Notify ntf);
void onNewReinvite(ReInvite event);
void onNewInfo(SipInfo info) {}
}

class Notify {
Notify({this.request});
IncomingRequest? request;
}

class SipInfo {
SipInfo({this.contentType, this.body, this.request, this.originator});
String? contentType;
String? body;
IncomingRequest? request;
Originator? originator;
}

class ReInvite {
ReInvite({this.hasVideo, this.hasAudio, this.sdp, this.accept, this.reject});
bool? hasVideo;
Expand Down
Loading