Skip to content

Commit

Permalink
Merge pull request #1 from flutter-webrtc/master
Browse files Browse the repository at this point in the history
add status_code to progress event (flutter-webrtc#374)
  • Loading branch information
berger89 committed Jun 12, 2023
2 parents 2e1064c + dfead3f commit 0513faa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
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

0 comments on commit 0513faa

Please sign in to comment.