watchNotifications method
Subscribe to notifications from sing-box Returns Stream with notification updates
Implementation
@override
Stream<SingBoxNotification> watchNotifications() {
try {
final stream = notificationsEventChannel.receiveBroadcastStream();
return stream
.map((data) {
if (data is Map) {
return SingBoxNotification.fromMap(data.cast<dynamic, dynamic>());
}
throw Exception('Invalid notification data: $data');
})
.handleError((error) {
debugPrint('Error in notifications stream: $error');
});
} catch (e) {
debugPrint('Error creating notifications stream: $e');
return const Stream<SingBoxNotification>.empty();
}
}