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 {
25
25
Map<int , RealtimeSubscription > _subscriptions = {};
26
26
bool _notifyDone = true;
27
27
StreamSubscription? _websocketSubscription;
28
+ bool _creatingSocket = false;
28
29
29
30
Future<dynamic > _closeConnection() async {
30
31
await _websocketSubscription?.cancel();
@@ -33,12 +34,15 @@ mixin RealtimeMixin {
33
34
}
34
35
35
36
_createSocket() async {
37
+ if(_creatingSocket) return;
38
+ _creatingSocket = true;
36
39
final uri = _prepareUri();
37
40
if (_websok == null) {
38
41
_websok = await getWebSocket(uri);
39
42
_lastUrl = uri.toString();
40
43
} else {
41
44
if (_lastUrl == uri.toString() && _websok?.closeCode == null) {
45
+ _creatingSocket = false;
42
46
return;
43
47
}
44
48
_notifyDone = false;
@@ -107,6 +111,8 @@ mixin RealtimeMixin {
107
111
throw {{spec .title | caseUcfirst }}Exception(e.message);
108
112
}
109
113
throw {{spec .title | caseUcfirst }}Exception(e.toString());
114
+ } finally {
115
+ _creatingSocket = false;
110
116
}
111
117
}
112
118
You can’t perform that action at this time.
0 commit comments