setPing method

void setPing()

Pings server every this.pingInterval and expects response within this.pingTimeout or closes connection.

@api private

Implementation

void setPing() {
  if (pingIntervalTimer != null) {
    pingIntervalTimer!.cancel();
  }
  pingIntervalTimer = Timer(Duration(milliseconds: pingInterval!), () {
    _logger
        .fine('writing ping packet - expecting pong within ${pingTimeout}ms');
    ping();
    onHeartbeat(pingTimeout);
  });
}