Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add status_code to progress event (#374) #1

Merged
merged 1 commit into from
Jun 12, 2023
Merged
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
4 changes: 3 additions & 1 deletion lib/src/event_manager/call_events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ class EventCallEnded extends CallEvent {
}

class EventCallProgress extends CallEvent {
EventCallProgress({RTCSession? session, this.originator, this.response})
EventCallProgress(
{RTCSession? session, this.originator, this.response, this.cause})
: super(session);
String? originator;
dynamic response;
ErrorCause? cause;
}

class EventCallConfirmed extends CallEvent {
Expand Down
12 changes: 9 additions & 3 deletions lib/src/rtc_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,7 @@ class RTCSession extends EventManager implements Owner {
}

_status = C.STATUS_1XX_RECEIVED;
_progress('remote', response);
_progress('remote', response, int.parse(status_code));

if (response.body == null || response.body!.isEmpty) {
return;
Expand Down Expand Up @@ -2916,11 +2916,17 @@ class RTCSession extends EventManager implements Owner {
emit(EventCallConnecting(session: this, request: request));
}

void _progress(String originator, dynamic response) {
void _progress(String originator, dynamic response, [int? status_code]) {
logger.d('session progress');
logger.d('emit "progress"');

ErrorCause errorCause = ErrorCause(status_code: status_code);

emit(EventCallProgress(
session: this, originator: originator, response: response));
session: this,
originator: originator,
response: response,
cause: errorCause));
}

void _accepted(String originator, [dynamic message]) {
Expand Down
6 changes: 4 additions & 2 deletions lib/src/sip_ua_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ class SIPUAHelper extends EventManager {
});
handlers.on(EventCallProgress(), (EventCallProgress event) {
logger.d('call is in progress');
_notifyCallStateListeners(event,
CallState(CallStateEnum.PROGRESS, originator: event.originator));
_notifyCallStateListeners(
event,
CallState(CallStateEnum.PROGRESS,
originator: event.originator, cause: event.cause));
});
handlers.on(EventCallFailed(), (EventCallFailed event) {
logger.d('call failed with cause: ${event.cause}');
Expand Down