schedulePing method

  1. @visibleForOverriding
Future<void> schedulePing()

Schedule a ping to be sent after a given amount of time. Can be overriden for custom timing mechanisms. By default, uses a Timer.periodic timer to trigger a ping. NOTE: This function is called whenever the connection is re-established. Custom implementations should thus guard against multiple timers being started.

Implementation

@visibleForOverriding
Future<void> schedulePing() async {
  await _timerLock.synchronized(() {
    logger.finest('Scheduling new timer? ${_pingTimer != null}');

    _pingTimer ??= Timer.periodic(
      _pingDuration,
      _sendPing,
    );
  });
}