terminate method

  1. @override
Future<TcccOutcome> terminate()
override

Implementation

@override
Future<TcccOutcome> terminate() async {
  terminateCount += 1;
  if (isEnded) {
    return TcccOutcome.fail(
      TcccFailure(
        code: ErrorCode.Session.invalidState,
        message: 'call already ended; terminate ignored',
      ),
    );
  }
  final reason = status.state == TcccCallState.accepted
      ? TcccCause.terminated
      : TcccCause.canceled;
  final now = DateTime.utc(2026, 1, 1, 12, 0, 8);
  completeDone(
    TcccCallResult(
      callId: callId,
      channelId: channelId,
      cause: reason,
      causeMessage: reason.value,
      originator: TcccOriginator.local,
      startedAt: startedAt,
      ringingAt: status.ringingAt,
      connectedAt: status.connectedAt,
      endedAt: now,
    ),
  );
  return const TcccOutcome.ok();
}