connectionEvents property
Stream<SyncConnectionEvent>
get
connectionEvents
A broadcast stream of connection state changes (connect/disconnect).
Subscribe (listen) to the stream to start receiving events. Cancel the subscription when no longer needed to free resources.
Implementation
Stream<SyncConnectionEvent> get connectionEvents {
if (_connectionEvents == null) {
// Combine events from two C listeners: connect & disconnect.
_connectionEvents =
_SyncListenerGroup<SyncConnectionEvent>('sync-connection');
_connectionEvents!.add(_SyncListenerConfig(
(int nativePort) => C.dartc_sync_listener_connect(_ptr, nativePort),
(dynamic _, controller) =>
controller.add(SyncConnectionEvent.connected)));
_connectionEvents!.add(_SyncListenerConfig(
(int nativePort) =>
C.dartc_sync_listener_disconnect(_ptr, nativePort),
(dynamic _, controller) =>
controller.add(SyncConnectionEvent.disconnected)));
_connectionEvents!.finish();
}
return _connectionEvents!.stream;
}