@@ -22,6 +22,7 @@ class Subscription<T extends ParseObject> {
2222 'error'
2323 ];
2424 Map <String , Function > eventCallbacks = < String , Function > {};
25+
2526 void on (LiveQueryEvent op, Function callback) {
2627 eventCallbacks[_liveQueryEvent[op.index]] = callback;
2728 }
@@ -140,8 +141,10 @@ class LiveQueryClient {
140141 reconnectingController = LiveQueryReconnectingController (
141142 () => reconnect (userInitialized: false ), getClientEventStream, _debug);
142143 }
144+
143145 static LiveQueryClient get instance => _getInstance ();
144146 static LiveQueryClient ? _instance;
147+
145148 static LiveQueryClient _getInstance ({bool ? debug, bool ? autoSendSessionId}) {
146149 String ? liveQueryURL = ParseCoreData ().liveQueryURL;
147150 if (liveQueryURL == null ) {
@@ -174,13 +177,14 @@ class LiveQueryClient {
174177 bool _connecting = false ;
175178 late StreamController <LiveQueryClientEvent > _clientEventStreamController;
176179 late Stream <LiveQueryClientEvent > _clientEventStream;
180+ StreamController <String >? chanelStream;
177181 late LiveQueryReconnectingController reconnectingController;
178182
179183 final Map <int , Subscription > _requestSubscription = < int , Subscription > {};
180184
181185 Future <void > reconnect ({bool userInitialized = false }) async {
182186 await _connect (userInitialized: userInitialized);
183- _connectLiveQuery ();
187+ await _connectLiveQuery ();
184188 }
185189
186190 int readyState () {
@@ -286,6 +290,8 @@ class LiveQueryClient {
286290 _channel = channel;
287291 channel.stream.listen ((dynamic message) {
288292 _handleMessage (message);
293+
294+ chanelStream? .sink.add (message);
289295 }, onDone: () {
290296 _clientEventStreamController.sink
291297 .add (LiveQueryClientEvent .disconnected);
@@ -315,7 +321,7 @@ class LiveQueryClient {
315321 }
316322 }
317323
318- void _connectLiveQuery () {
324+ Future < void > _connectLiveQuery () async {
319325 WebSocketChannel ? channel = _channel;
320326 if (channel == null ) {
321327 return ;
@@ -333,10 +339,22 @@ class LiveQueryClient {
333339 connectMessage['sessionToken' ] = sessionId;
334340 }
335341 }
342+
336343 String ? clientKey = ParseCoreData ().clientKey;
344+ if (clientKey != null ) {
345+ connectMessage['clientKey' ] = clientKey;
346+ }
347+
337348 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+ }
340358
341359 if (_debug) {
342360 print ('$_printConstLiveQuery : ConnectMessage: $connectMessage ' );
0 commit comments