ping method

Future<bool> ping({
  1. Duration timeout = const Duration(seconds: 1),
})
inherited

Pings the peer, and returns whether or not it responded within timeout.

The returned future completes after one of the following:

  • The peer responds (returns true).
  • The timeout is exceeded (returns false).

If the timeout is reached, future values or errors from the ping request are ignored.

Implementation

Future<bool> ping({Duration timeout = const Duration(seconds: 1)}) =>
    sendRequest<EmptyResult>(
      PingRequest.methodName,
      null,
    ).then((_) => true).timeout(timeout, onTimeout: () => false);