respondSessionRequest method

  1. @override
Future<void> respondSessionRequest({
  1. required String topic,
  2. required JsonRpcResponse response,
})
override

Implementation

@override
Future<void> respondSessionRequest({
  required String topic,
  required JsonRpcResponse response,
}) async {
  _checkInitialized();
  await _isValidResponse(topic, response);

  final session = sessions.get(topic);
  final isLinkModeSession = session?.transportType.isLinkMode ?? false;
  if (!isLinkModeSession) {
    _confirmOnlineStateOrThrow();
  }

  final appLink = _getAppLinkIfEnabled(session?.peer.metadata);

  if (response.result != null) {
    await core.pairing.sendResult(
      response.id,
      topic,
      MethodConstants.WC_SESSION_REQUEST,
      response.result,
      appLink: appLink,
    );
  } else {
    await core.pairing.sendError(
      response.id,
      topic,
      MethodConstants.WC_SESSION_REQUEST,
      response.error!,
      appLink: appLink,
    );
  }

  await _deletePendingRequest(response.id);
}