pingServer method
Future<VpnPingResult>
pingServer({
- required String host,
- required int port,
- Duration timeout = const Duration(seconds: 3),
- bool useTls = false,
- String? tlsServerName,
- bool allowInsecure = false,
override
Performs ping over TCP/TLS through native platform implementation.
Implementation
@override
/// Performs ping over TCP/TLS through native platform implementation.
Future<VpnPingResult> pingServer({
required String host,
required int port,
Duration timeout = const Duration(seconds: 3),
bool useTls = false,
String? tlsServerName,
bool allowInsecure = false,
}) async {
final dynamic raw = await methodChannel
.invokeMethod<dynamic>('pingServer', <String, Object?>{
'host': host,
'port': port,
'timeoutMs': timeout.inMilliseconds,
'useTls': useTls,
'tlsServerName': tlsServerName,
'allowInsecure': allowInsecure,
});
if (raw is Map<Object?, Object?>) {
return VpnPingResult.fromMap(raw, host: host, port: port);
}
return VpnPingResult.failure(
host: host,
port: port,
error: 'Invalid ping response',
);
}