close method

void close()

Implementation

void close() async {
  if (state == WhipState.kDisconnected) {
    return;
  }
  log.debug('Closing whip connection');
  await pc?.close();
  try {
    if (resourceURL == null) {
      throw 'Resource url not found!';
    }
    await httpDelete(Uri.parse(resourceURL ?? url));
  } catch (e) {
    log.error('connect error: $e');
    setState(WhipState.kFailure);
    lastError = e;
    return;
  }
  setState(WhipState.kDisconnected);
}