@@ -20,8 +20,8 @@ mixin RealtimeMixin {
2020 late WebSocketFactory getWebSocket;
2121 GetFallbackCookie? getFallbackCookie;
2222
23- _closeConnection() {
24- _websok?.sink.close(normalClosure);
23+ Future< dynamic > _closeConnection() async {
24+ return await _websok?.sink.close(normalClosure);
2525 }
2626
2727 _createSocket() async {
@@ -32,7 +32,7 @@ mixin RealtimeMixin {
3232 if (_lastUrl == uri.toString() && _websok?.closeCode == null) {
3333 return;
3434 }
35- _closeConnection();
35+ await _closeConnection();
3636 _lastUrl = uri.toString();
3737 print('subscription: $_lastUrl');
3838 _websok = await getWebSocket(uri);
@@ -112,7 +112,7 @@ mixin RealtimeMixin {
112112 Future.delayed(Duration.zero, () => _createSocket());
113113 RealtimeSubscription subscription = RealtimeSubscription(
114114 stream: controller.stream,
115- close: () {
115+ close: () async {
116116 controller.close();
117117 channels.forEach((channel) {
118118 this._channels[channel]!.remove(controller);
@@ -121,9 +121,9 @@ mixin RealtimeMixin {
121121 }
122122 });
123123 if(this._channels.isNotEmpty) {
124- Future.delayed(Duration.zero, () => _createSocket());
124+ await Future.delayed(Duration.zero, () => _createSocket());
125125 } else {
126- _closeConnection();
126+ await _closeConnection();
127127 }
128128 });
129129 return subscription;
0 commit comments