dart-sip-ua icon indicating copy to clipboard operation
dart-sip-ua copied to clipboard

Attended call transfer

Open DeviArunaMurugan opened this issue 1 year ago • 6 comments

https://github.com/flutter-webrtc/dart-sip-ua/issues/198

If you share the code for attended call transfer would be appreciated, as the continuation of above thread

DeviArunaMurugan avatar Apr 25 '23 06:04 DeviArunaMurugan

I join too, I really need an example

clover-soft avatar May 10 '23 22:05 clover-soft

I've got a working example. Right now this example will not work with the master branch or version 0.5.8

You need to expose from_tag and to_tag in rtc_session.dart ~line 90 like below:

  String? _from_tag;
  String? get from_tag => _from_tag;
  String? _to_tag;
  String? get to_tag => _to_tag;

This is what melio-matt suggested in https://github.com/flutter-webrtc/dart-sip-ua/issues/198

After exposing the from/to_tag, you can create an extension function to extend the normal Call class.


class _Replaces {
  _Replaces({
    required this.call_id,
    required this.from_tag,
    required this.to_tag,
  });

  final String call_id;
  final String to_tag;
  final String from_tag;
}

extension ExtendedCall on Call {
  /// https://github.com/flutter-webrtc/dart-sip-ua/issues/198
  void attendedRefer(
    Call callToTransferTo,
  ) {
    final log = GetIt.I<AppLogger>().log;
    session.hold();

    // the call id has the from tag appended to it so we need to remove
    String callId = callToTransferTo.session.id!;
    callId = callId.substring(
      0,
      callId.length - callToTransferTo.session.from_tag!.length,
    );

    ReferSubscriber refer = session.refer(callToTransferTo.remote_identity, {
      'replaces': _Replaces(
        call_id: callId,
        from_tag: callToTransferTo.session.from_tag!,
        to_tag: callToTransferTo.session.to_tag!,
      ),
    })!;

    refer.on(EventReferTrying(), (EventReferTrying data) {});
    refer.on(EventReferProgress(), (EventReferProgress data) {});
    refer.on(EventReferAccepted(), (EventReferAccepted data) {
      session.terminate();
      log.i('refered call accepted');
    });
    refer.on(EventReferFailed(), (EventReferFailed data) {
      log.e('refer failed | ${data.status_line}');
    });
  }
}

ftsef avatar Jun 16 '23 07:06 ftsef

Could you give a simple example of use?

EliasBarrera avatar Nov 08 '23 15:11 EliasBarrera