@@ -27,12 +27,42 @@ class Manager extends EventEmitter {
27
27
List subs = [];
28
28
late Map options;
29
29
30
- bool ? _reconnection;
31
- num ? _reconnectionAttempts;
32
- num ? _reconnectionDelay;
30
+ ///
31
+ /// Sets the `reconnection` config.
32
+ ///
33
+ /// @param {Boolean} true/false if it should automatically reconnect
34
+ /// @return {Manager} self or value
35
+ /// @api public
36
+ ///
37
+ bool ? reconnection;
38
+
39
+ ///
40
+ /// Sets the reconnection attempts config.
41
+ ///
42
+ /// @param {Number} max reconnection attempts before giving up
43
+ /// @return {Manager} self or value
44
+ /// @api public
45
+ ///
46
+ num ? reconnectionAttempts;
47
+
48
+ ///
49
+ /// Sets the delay between reconnections.
50
+ ///
51
+ /// @param {Number} delay
52
+ /// @return {Manager} self or value
53
+ /// @api public
54
+ ///
55
+ num ? reconnectionDelay;
33
56
num ? _randomizationFactor;
34
57
num ? _reconnectionDelayMax;
35
- num ? _timeout;
58
+
59
+ ///
60
+ /// Sets the connection timeout. `false` to disable
61
+ ///
62
+ /// @return {Manager} self or value
63
+ /// @api public
64
+ ///
65
+ num ? timeout;
36
66
_Backoff ? backoff;
37
67
String readyState = 'closed' ;
38
68
late String uri;
@@ -103,36 +133,6 @@ class Manager extends EventEmitter {
103
133
return (nsp.isEmpty ? '' : (nsp + '#' )) + (engine.id ?? '' );
104
134
}
105
135
106
- ///
107
- /// Sets the `reconnection` config.
108
- ///
109
- /// @param {Boolean} true/false if it should automatically reconnect
110
- /// @return {Manager} self or value
111
- /// @api public
112
- ///
113
- bool ? get reconnection => _reconnection;
114
- set reconnection (bool ? v) => _reconnection = v;
115
-
116
- ///
117
- /// Sets the reconnection attempts config.
118
- ///
119
- /// @param {Number} max reconnection attempts before giving up
120
- /// @return {Manager} self or value
121
- /// @api public
122
- ///
123
- num ? get reconnectionAttempts => _reconnectionAttempts;
124
- set reconnectionAttempts (num ? v) => _reconnectionAttempts = v;
125
-
126
- ///
127
- /// Sets the delay between reconnections.
128
- ///
129
- /// @param {Number} delay
130
- /// @return {Manager} self or value
131
- /// @api public
132
- ///
133
- num ? get reconnectionDelay => _reconnectionDelay;
134
- set reconnectionDelay (num ? v) => _reconnectionDelay = v;
135
-
136
136
num ? get randomizationFactor => _randomizationFactor;
137
137
set randomizationFactor (num ? v) {
138
138
_randomizationFactor = v;
@@ -152,15 +152,6 @@ class Manager extends EventEmitter {
152
152
backoff? .max = v;
153
153
}
154
154
155
- ///
156
- /// Sets the connection timeout. `false` to disable
157
- ///
158
- /// @return {Manager} self or value
159
- /// @api public
160
- ///
161
- num ? get timeout => _timeout;
162
- set timeout (num ? v) => _timeout = v;
163
-
164
155
///
165
156
/// Starts trying to reconnect if reconnection is enabled and we have not
166
157
/// started reconnecting yet
@@ -169,7 +160,7 @@ class Manager extends EventEmitter {
169
160
///
170
161
void maybeReconnectOnOpen () {
171
162
// Only try to reconnect if it's the first time we're connecting
172
- if (! reconnecting && _reconnection == true && backoff! .attempts == 0 ) {
163
+ if (! reconnecting && reconnection == true && backoff! .attempts == 0 ) {
173
164
// keeps reconnection from firing twice for the same reconnection loop
174
165
reconnect ();
175
166
}
@@ -216,12 +207,11 @@ class Manager extends EventEmitter {
216
207
});
217
208
218
209
// emit `connect_timeout`
219
- if (_timeout != null ) {
220
- var timeout = _timeout! ;
210
+ if (timeout != null ) {
221
211
_logger.fine ('connect attempt will timeout after $timeout ' );
222
212
223
213
// set timer
224
- var timer = Timer (Duration (milliseconds: timeout.toInt ()), () {
214
+ var timer = Timer (Duration (milliseconds: timeout! .toInt ()), () {
225
215
_logger.fine ('connect attempt timed out after $timeout ' );
226
216
openSub.destroy ();
227
217
socket.close ();
@@ -448,7 +438,7 @@ class Manager extends EventEmitter {
448
438
readyState = 'closed' ;
449
439
emit ('close' , error['reason' ]);
450
440
451
- if (_reconnection == true && ! skipReconnect! ) {
441
+ if (reconnection == true && ! skipReconnect! ) {
452
442
reconnect ();
453
443
}
454
444
}
@@ -461,7 +451,7 @@ class Manager extends EventEmitter {
461
451
Manager reconnect () {
462
452
if (reconnecting || skipReconnect! ) return this ;
463
453
464
- if (backoff! .attempts >= _reconnectionAttempts ! ) {
454
+ if (backoff! .attempts >= reconnectionAttempts ! ) {
465
455
_logger.fine ('reconnect failed' );
466
456
backoff! .reset ();
467
457
emitAll ('reconnect_failed' );
0 commit comments