File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
templates/flutter/lib/src Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ mixin RealtimeMixin {
2525 Map<int , RealtimeSubscription > _subscriptions = {};
2626 bool _notifyDone = true;
2727 StreamSubscription? _websocketSubscription;
28+ bool _creatingSocket = false;
2829
2930 Future<dynamic > _closeConnection() async {
3031 await _websocketSubscription?.cancel();
@@ -33,12 +34,15 @@ mixin RealtimeMixin {
3334 }
3435
3536 _createSocket() async {
37+ if(_creatingSocket) return;
38+ _creatingSocket = true;
3639 final uri = _prepareUri();
3740 if (_websok == null) {
3841 _websok = await getWebSocket(uri);
3942 _lastUrl = uri.toString();
4043 } else {
4144 if (_lastUrl == uri.toString() && _websok?.closeCode == null) {
45+ _creatingSocket = false;
4246 return;
4347 }
4448 _notifyDone = false;
@@ -107,6 +111,8 @@ mixin RealtimeMixin {
107111 throw {{spec .title | caseUcfirst }}Exception(e.message);
108112 }
109113 throw {{spec .title | caseUcfirst }}Exception(e.toString());
114+ } finally {
115+ _creatingSocket = false;
110116 }
111117 }
112118
You can’t perform that action at this time.
0 commit comments