watchSingBoxConnectionStatus method
Subscribe to connection status changes Returns Stream with status updates
Implementation
@override
Stream<SingBoxConnectionStatus> watchSingBoxConnectionStatus() {
try {
return statusEventChannel
.receiveBroadcastStream()
.map((dynamic event) {
if (event is String) {
return SingBoxConnectionStatusExtension.fromString(event);
}
return SingBoxConnectionStatus.disconnected;
})
.handleError((error) {
debugPrint('Error in connection status stream: $error');
});
} catch (e) {
debugPrint('Error creating connection status stream: $e');
return Stream.value(SingBoxConnectionStatus.disconnected);
}
}