endCall method

void endCall(
  1. String? callID
)

Attempts to end the call identified via the callID

Implementation

void endCall(String? callID) {
  var uuid = const Uuid().v4();
  var byeDialogParams = ByeDialogParams(callId: callID);

  var byeParams = SendByeParams(
      cause: CauseCode.USER_BUSY.name,
      causeCode: CauseCode.USER_BUSY.index + 1,
      dialogParams: byeDialogParams,
      sessid: _sessid);

  var byeMessage = SendByeMessage(
      id: uuid,
      jsonrpc: JsonRPCConstant.jsonrpc,
      method: SocketMethod.BYE,
      params: byeParams);

  String jsonByeMessage = jsonEncode(byeMessage);
  _txSocket.send(jsonByeMessage);
  if (peerConnection != null) {
    peerConnection?.closeSession(_sessid);
  }
  stopAudio();
  callEnded();
}