onPingTimer method

void onPingTimer(
  1. Timer? t
)

Implementation

void onPingTimer(Timer? t) {
  var currentTs = DateTime.now().millisecondsSinceEpoch;
  if (currentTs - _dataReceiveTs >= 65000) {
    // close the connection if no message received in the last 65 seconds
    close();
    return;
  }

  if (currentTs - _dataSentTs > 21000) {
    // add message if no data was sent in the last 21 seconds
    addConnCommand(null, null);
  }
}