connectionEvents property

Stream<ConnectionEvent> connectionEvents

Get a stream of ConnectionEvents.

If you want to get connection events when connecting to the eSense device, remember to start listening to this stream before attempting to connect.

For example.

    ESenseManager.connectionEvents.listen((event) => print('Connection event: $event'));
    bool success = await ESenseManager.connect(eSenseName);


static Stream<ConnectionEvent> get connectionEvents {
  if (_connectionEventStream == null) {
    _connectionEventStream =
        _eSenseConnectionEventChannel.receiveBroadcastStream().map((type) => ConnectionEvent.fromString(type));

    // listen to the connection event in order to set the [connection] status
    _connectionEventStream.listen((ConnectionEvent event) {
      switch (event.type) {
        case ConnectionType.connected:
          connected = true;
        case ConnectionType.disconnected:
        case ConnectionType.unknown:
        case ConnectionType.device_found:
        case ConnectionType.device_not_found:
          connected = false;
  return _connectionEventStream;