getServerDelay method

Future<int> getServerDelay({
  1. required String config,
  2. String url = 'https://google.com/generate_204',
})

Measures the delay to a V2Ray server using the provided configuration. config is the V2Ray configuration in JSON format. url is the server URL to test for delay (default is 'https://google.com/generate_204'). Throws an ArgumentError if the config is not valid JSON. Returns a Future that completes with the delay in milliseconds.

Implementation

Future<int> getServerDelay({
  required String config,
  String url = 'https://google.com/generate_204',
}) async {
  try {
    if (jsonDecode(config) == null) {
      throw ArgumentError('The provided string is not valid JSON');
    }
  } catch (_) {
    throw ArgumentError('The provided string is not valid JSON');
  }
  return FlutterV2rayPlatform.instance
      .getServerDelay(config: config, url: url);
}