@@ -38,7 +38,7 @@ pub struct StartSyncStream {
38
38
///
39
39
/// We will increase the expiry date for those streams at the time we connect and disconnect.
40
40
#[ serde( default ) ]
41
- pub active_streams : Vec < StreamKey > ,
41
+ pub active_streams : Rc < Vec < StreamKey > > ,
42
42
}
43
43
44
44
impl StartSyncStream {
@@ -89,6 +89,12 @@ pub enum SyncEvent<'a> {
89
89
TextLine { data : & ' a str } ,
90
90
/// Forward a binary line (BSON) received from the sync service.
91
91
BinaryLine { data : & ' a [ u8 ] } ,
92
+ /// The active stream subscriptions (as in, `SyncStreamSubscription` instances active right now)
93
+ /// have changed.
94
+ ///
95
+ /// The client will compare the new active subscriptions with the current one and will issue a
96
+ /// request to restart the sync iteration if necessary.
97
+ DidUpdateSubscriptions { active_streams : Rc < Vec < StreamKey > > } ,
92
98
}
93
99
94
100
/// An instruction sent by the core extension to the SDK.
@@ -114,13 +120,20 @@ pub enum Instruction {
114
120
// These are defined like this because deserializers in Kotlin can't support either an
115
121
// object or a literal value
116
122
/// Close the websocket / HTTP stream to the sync service.
117
- CloseSyncStream { } ,
123
+ CloseSyncStream ( CloseSyncStream ) ,
118
124
/// Flush the file-system if it's non-durable (only applicable to the Dart SDK).
119
125
FlushFileSystem { } ,
120
126
/// Notify that a sync has been completed, prompting client SDKs to clear earlier errors.
121
127
DidCompleteSync { } ,
122
128
}
123
129
130
+ #[ derive( Serialize , Default ) ]
131
+ pub struct CloseSyncStream {
132
+ /// Whether clients should hide the brief disconnected status from the public sync status and
133
+ /// reconnect immediately.
134
+ pub hide_disconnect : bool ,
135
+ }
136
+
124
137
#[ derive( Serialize ) ]
125
138
pub enum LogSeverity {
126
139
DEBUG ,
@@ -136,16 +149,16 @@ pub struct StreamingSyncRequest {
136
149
pub binary_data : bool ,
137
150
pub client_id : String ,
138
151
pub parameters : Option < serde_json:: Map < String , serde_json:: Value > > ,
139
- pub streams : StreamSubscriptionRequest ,
152
+ pub streams : Rc < StreamSubscriptionRequest > ,
140
153
}
141
154
142
- #[ derive( Serialize ) ]
155
+ #[ derive( Debug , Serialize , PartialEq ) ]
143
156
pub struct StreamSubscriptionRequest {
144
157
pub include_defaults : bool ,
145
158
pub subscriptions : Vec < RequestedStreamSubscription > ,
146
159
}
147
160
148
- #[ derive( Serialize ) ]
161
+ #[ derive( Debug , Serialize , PartialEq ) ]
149
162
pub struct RequestedStreamSubscription {
150
163
/// The name of the sync stream to subscribe to.
151
164
pub stream : String ,
@@ -223,6 +236,12 @@ pub fn register(db: *mut sqlite::sqlite3, state: Arc<DatabaseState>) -> Result<(
223
236
} ) ,
224
237
"refreshed_token" => SyncControlRequest :: SyncEvent ( SyncEvent :: DidRefreshToken ) ,
225
238
"completed_upload" => SyncControlRequest :: SyncEvent ( SyncEvent :: UploadFinished ) ,
239
+ "update_subscriptions" => {
240
+ SyncControlRequest :: SyncEvent ( SyncEvent :: DidUpdateSubscriptions {
241
+ active_streams : serde_json:: from_str ( payload. text ( ) )
242
+ . map_err ( PowerSyncError :: as_argument_error) ?,
243
+ } )
244
+ }
226
245
"subscriptions" => {
227
246
let request = serde_json:: from_str ( payload. text ( ) )
228
247
. map_err ( PowerSyncError :: as_argument_error) ?;
0 commit comments