@@ -27,12 +27,34 @@ 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
+ num ? reconnectionDelay;
33
48
num ? _randomizationFactor;
34
49
num ? _reconnectionDelayMax;
35
- num ? _timeout;
50
+
51
+ ///
52
+ /// Sets the connection timeout. `false` to disable
53
+ ///
54
+ /// @return {Manager} self or value
55
+ /// @api public
56
+ ///
57
+ num ? timeout;
36
58
_Backoff ? backoff;
37
59
String readyState = 'closed' ;
38
60
late String uri;
@@ -103,36 +125,6 @@ class Manager extends EventEmitter {
103
125
return (nsp.isEmpty ? '' : (nsp + '#' )) + (engine.id ?? '' );
104
126
}
105
127
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
128
num ? get randomizationFactor => _randomizationFactor;
137
129
set randomizationFactor (num ? v) {
138
130
_randomizationFactor = v;
@@ -152,15 +144,6 @@ class Manager extends EventEmitter {
152
144
backoff? .max = v;
153
145
}
154
146
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
147
///
165
148
/// Starts trying to reconnect if reconnection is enabled and we have not
166
149
/// started reconnecting yet
@@ -169,7 +152,7 @@ class Manager extends EventEmitter {
169
152
///
170
153
void maybeReconnectOnOpen () {
171
154
// Only try to reconnect if it's the first time we're connecting
172
- if (! reconnecting && _reconnection == true && backoff! .attempts == 0 ) {
155
+ if (! reconnecting && reconnection == true && backoff! .attempts == 0 ) {
173
156
// keeps reconnection from firing twice for the same reconnection loop
174
157
reconnect ();
175
158
}
@@ -216,8 +199,8 @@ class Manager extends EventEmitter {
216
199
});
217
200
218
201
// emit `connect_timeout`
219
- if (_timeout != null ) {
220
- var timeout = _timeout ! ;
202
+ var timeout = this .timeout;
203
+ if ( timeout != null ) {
221
204
_logger.fine ('connect attempt will timeout after $timeout ' );
222
205
223
206
// set timer
@@ -450,7 +433,7 @@ class Manager extends EventEmitter {
450
433
readyState = 'closed' ;
451
434
emit ('close' , error['reason' ]);
452
435
453
- if (_reconnection == true && ! skipReconnect! ) {
436
+ if (reconnection == true && ! skipReconnect! ) {
454
437
reconnect ();
455
438
}
456
439
}
@@ -463,7 +446,7 @@ class Manager extends EventEmitter {
463
446
Manager reconnect () {
464
447
if (reconnecting || skipReconnect! ) return this ;
465
448
466
- if (backoff! .attempts >= _reconnectionAttempts ! ) {
449
+ if (backoff! .attempts >= reconnectionAttempts ! ) {
467
450
_logger.fine ('reconnect failed' );
468
451
backoff! .reset ();
469
452
emitAll ('reconnect_failed' );
0 commit comments