Skip to content

Commit ba3d399

Browse files
committed
Expose Client::handle_notifications
1 parent a7a084d commit ba3d399

File tree

11 files changed

+1478
-300
lines changed

11 files changed

+1478
-300
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
* Expose `EventBuilder::gift_wrap` ([Yuki Kishimoto])
4040
* Expose `EventBuilder::private_msg` ([Yuki Kishimoto])
4141
* Expose `UnwrappedGift` ([Yuki Kishimoto])
42+
* Expose `Client::handle_notifications` ([Yuki Kishimoto])
4243

4344
### Fixed
4445

lib/nostr_sdk.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export 'src/rust/api/protocol/signer.dart';
1616
export 'src/rust/api/relay/options.dart';
1717
export 'src/rust/api/client.dart';
1818
export 'src/rust/api/client/builder.dart';
19+
export 'src/rust/api/client/notification.dart';
1920
export 'src/rust/api/client/options.dart';
2021
export 'src/rust/api/client/output.dart';

lib/src/rust/api/client.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import '../frb_generated.dart';
77
import 'client/builder.dart';
8+
import 'client/notification.dart';
89
import 'client/output.dart';
910
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
1011
import 'protocol/event.dart';
@@ -83,6 +84,8 @@ abstract class Client implements RustOpaqueInterface {
8384
/// Note: this method will remove the relay, also if it's in use for the gossip model or other service!
8485
Future<void> forceRemoveRelay({required String url});
8586

87+
Stream<RelayPoolNotification> handleNotifications();
88+
8689
/// Check if signer is configured
8790
Future<bool> hasSigner();
8891

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// This file is automatically generated, so please do not edit it.
2+
// Generated by `flutter_rust_bridge`@ 2.0.0.
3+
4+
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
5+
6+
import '../../frb_generated.dart';
7+
import '../protocol/event.dart';
8+
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
9+
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
10+
part 'notification.freezed.dart';
11+
12+
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `from`
13+
14+
@freezed
15+
sealed class RelayPoolNotification with _$RelayPoolNotification {
16+
const RelayPoolNotification._();
17+
18+
/// Received an [`Event`]. Does not include events sent by this client.
19+
const factory RelayPoolNotification.event({
20+
/// Relay url
21+
required String relayUrl,
22+
23+
/// Subscription ID
24+
required String subscriptionId,
25+
26+
/// Event
27+
required Event event,
28+
}) = RelayPoolNotification_Event;
29+
30+
/// Received a [`RelayMessage`]. Includes messages wrapping events that were sent by this client.
31+
const factory RelayPoolNotification.message({
32+
/// Relay url
33+
required String relayUrl,
34+
35+
/// Relay Message
36+
required String message,
37+
}) = RelayPoolNotification_Message;
38+
39+
/// Shutdown
40+
///
41+
/// This notification variant is sent after [`Client::shutdown`] method is called and all connections have been closed.
42+
const factory RelayPoolNotification.shutdown() =
43+
RelayPoolNotification_Shutdown;
44+
}

0 commit comments

Comments
 (0)