connectionStatusStream method

Stream<bool> connectionStatusStream()

Create a stream that represents the status of the connection to the NT4 server

Implementation

Stream<bool> connectionStatusStream() async* {
  yield _serverConnectionActive;
  bool lastYielded = _serverConnectionActive;

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