pingServer static method
Ping server (legacy method)
Implementation
static void pingServer({required int subscriptionIndex, required int index}) async {
try {
if (subscriptionIndex >= _loadedSubscriptions.length) {
return;
}
final subscription = _loadedSubscriptions[subscriptionIndex];
if (index >= subscription.servers.length) {
return;
}
final server = subscription.servers[index];
final engine = VpnEngineFactory.create(EngineType.libxray);
if (engine != null && engine.isSupported) {
final latency = await engine.ping(server.config, 'https://www.google.com', timeout: 5);
_updatePingResult(PingResult(serverIndex: index, latencyInMs: latency));
}
} catch (e) {
print('Error pinging server: $e');
}
}