@@ -22,6 +22,7 @@ class Subscription<T extends ParseObject> {
22
22
'error'
23
23
];
24
24
Map <String , Function > eventCallbacks = < String , Function > {};
25
+
25
26
void on (LiveQueryEvent op, Function callback) {
26
27
eventCallbacks[_liveQueryEvent[op.index]] = callback;
27
28
}
@@ -140,8 +141,10 @@ class LiveQueryClient {
140
141
reconnectingController = LiveQueryReconnectingController (
141
142
() => reconnect (userInitialized: false ), getClientEventStream, _debug);
142
143
}
144
+
143
145
static LiveQueryClient get instance => _getInstance ();
144
146
static LiveQueryClient ? _instance;
147
+
145
148
static LiveQueryClient _getInstance ({bool ? debug, bool ? autoSendSessionId}) {
146
149
String ? liveQueryURL = ParseCoreData ().liveQueryURL;
147
150
if (liveQueryURL == null ) {
@@ -174,13 +177,14 @@ class LiveQueryClient {
174
177
bool _connecting = false ;
175
178
late StreamController <LiveQueryClientEvent > _clientEventStreamController;
176
179
late Stream <LiveQueryClientEvent > _clientEventStream;
180
+ StreamController <String >? chanelStream;
177
181
late LiveQueryReconnectingController reconnectingController;
178
182
179
183
final Map <int , Subscription > _requestSubscription = < int , Subscription > {};
180
184
181
185
Future <void > reconnect ({bool userInitialized = false }) async {
182
186
await _connect (userInitialized: userInitialized);
183
- _connectLiveQuery ();
187
+ await _connectLiveQuery ();
184
188
}
185
189
186
190
int readyState () {
@@ -286,6 +290,8 @@ class LiveQueryClient {
286
290
_channel = channel;
287
291
channel.stream.listen ((dynamic message) {
288
292
_handleMessage (message);
293
+
294
+ chanelStream? .sink.add (message);
289
295
}, onDone: () {
290
296
_clientEventStreamController.sink
291
297
.add (LiveQueryClientEvent .disconnected);
@@ -315,7 +321,7 @@ class LiveQueryClient {
315
321
}
316
322
}
317
323
318
- void _connectLiveQuery () {
324
+ Future < void > _connectLiveQuery () async {
319
325
WebSocketChannel ? channel = _channel;
320
326
if (channel == null ) {
321
327
return ;
@@ -333,10 +339,22 @@ class LiveQueryClient {
333
339
connectMessage['sessionToken' ] = sessionId;
334
340
}
335
341
}
342
+
336
343
String ? clientKey = ParseCoreData ().clientKey;
344
+ if (clientKey != null ) {
345
+ connectMessage['clientKey' ] = clientKey;
346
+ }
347
+
337
348
String ? masterKey = ParseCoreData ().masterKey;
338
- if (clientKey != null ) connectMessage['clientKey' ] = clientKey;
339
- if (masterKey != null ) connectMessage['masterKey' ] = masterKey;
349
+ if (masterKey != null ) {
350
+ connectMessage['masterKey' ] = masterKey;
351
+ }
352
+
353
+ String ? parseInstallation =
354
+ (await ParseInstallation .currentInstallation ()).installationId;
355
+ if (parseInstallation != null ) {
356
+ connectMessage['installationId' ] = parseInstallation;
357
+ }
340
358
341
359
if (_debug) {
342
360
print ('$_printConstLiveQuery : ConnectMessage: $connectMessage ' );
0 commit comments