latencyStream method

Stream<int> latencyStream()

Creates a stream of the latency in milliseconds from the program to the NT4 server

Implementation

Stream<int> latencyStream() async* {
  yield _latencyMs;
  int lastYielded = _latencyMs;

  while (true) {
    await Future.delayed(Duration(seconds: 1));
    if (_latencyMs != lastYielded) {
      yield _latencyMs;
      lastYielded = _latencyMs;
    }
  }
}