Skip to content

Commit 52c278d

Browse files
committed
Resolve #163 Null safety support for 2.0.0-beta
1 parent ee1eb66 commit 52c278d

9 files changed

+63
-61
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.0.0-beta.3-nullsafety.0
2+
3+
**New Feature:**
4+
5+
* [#163](https://github.com/rikulo/socket.io-client-dart/issues/163) Null safety support for 2.0.0-beta
6+
17
## 2.0.0-beta.3
28

39
**Bug fix:**
@@ -17,6 +23,11 @@
1723
* [#130](https://github.com/rikulo/socket.io-client-dart/issues/130) Cannot connect to socket.io V3
1824
* [#106](https://github.com/rikulo/socket.io-client-dart/issues/106) Can we combine emitWithBinary to emit?
1925

26+
## 1.0.0-nullsafety.0
27+
28+
**New Feature:**
29+
30+
* [#132](https://github.com/rikulo/socket.io-client-dart/issues/132) Migrating to null safety for Dart
2031

2132
## 0.9.12
2233

analysis_options.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:pedantic/analysis_options.yaml
1+
include: package:pedantic/analysis_options.1.9.0.yaml
22

33
analyzer:
44
# exclude:

lib/src/engine/socket.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ class Socket extends EventEmitter {
465465
break;
466466
}
467467
} else {
468-
_logger.fine('packet received with socket readyState "${readyState}"');
468+
_logger.fine('packet received with socket readyState "$readyState"');
469469
}
470470
}
471471

lib/src/engine/transport/jsonp_transport.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class JSONPTransport extends PollingTransport {
145145
if (form == null) {
146146
var form = document.createElement('form') as FormElement;
147147
var area = document.createElement('textarea') as TextAreaElement;
148-
var id = iframeId = 'eio_iframe_${index}';
148+
var id = iframeId = 'eio_iframe_$index';
149149

150150
form.className = 'socketio';
151151
form.style.position = 'absolute';

lib/src/engine/transport/polling_transport.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ abstract class PollingTransport extends Transport {
138138
if ('open' == readyState) {
139139
poll();
140140
} else {
141-
_logger.fine('ignoring poll - transport state "${readyState}"');
141+
_logger.fine('ignoring poll - transport state "$readyState"');
142142
}
143143
}
144144
}

lib/src/engine/transport/xhr_transport.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class Request extends EventEmitter {
160160
var self = this;
161161

162162
try {
163-
_logger.fine('xhr open ${method}: ${uri}');
163+
_logger.fine('xhr open $method: $uri');
164164
xhr.open(method, uri, async: async);
165165

166166
try {
@@ -233,7 +233,7 @@ class Request extends EventEmitter {
233233
});
234234
/*}*/
235235

236-
_logger.fine('xhr data ${data}');
236+
_logger.fine('xhr data $data');
237237
xhr.send(data);
238238
} catch (e) {
239239
// Need to defer since .create() is called directly fhrom the constructor

lib/src/manager.dart

+39-49
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,42 @@ class Manager extends EventEmitter {
2727
List subs = [];
2828
late Map options;
2929

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;
3356
num? _randomizationFactor;
3457
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;
3666
_Backoff? backoff;
3767
String readyState = 'closed';
3868
late String uri;
@@ -103,36 +133,6 @@ class Manager extends EventEmitter {
103133
return (nsp.isEmpty ? '' : (nsp + '#')) + (engine.id ?? '');
104134
}
105135

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-
136136
num? get randomizationFactor => _randomizationFactor;
137137
set randomizationFactor(num? v) {
138138
_randomizationFactor = v;
@@ -152,15 +152,6 @@ class Manager extends EventEmitter {
152152
backoff?.max = v;
153153
}
154154

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-
164155
///
165156
/// Starts trying to reconnect if reconnection is enabled and we have not
166157
/// started reconnecting yet
@@ -169,7 +160,7 @@ class Manager extends EventEmitter {
169160
///
170161
void maybeReconnectOnOpen() {
171162
// 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) {
173164
// keeps reconnection from firing twice for the same reconnection loop
174165
reconnect();
175166
}
@@ -216,12 +207,11 @@ class Manager extends EventEmitter {
216207
});
217208

218209
// emit `connect_timeout`
219-
if (_timeout != null) {
220-
var timeout = _timeout!;
210+
if (timeout != null) {
221211
_logger.fine('connect attempt will timeout after $timeout');
222212

223213
// set timer
224-
var timer = Timer(Duration(milliseconds: timeout.toInt()), () {
214+
var timer = Timer(Duration(milliseconds: timeout!.toInt()), () {
225215
_logger.fine('connect attempt timed out after $timeout');
226216
openSub.destroy();
227217
socket.close();
@@ -448,7 +438,7 @@ class Manager extends EventEmitter {
448438
readyState = 'closed';
449439
emit('close', error['reason']);
450440

451-
if (_reconnection == true && !skipReconnect!) {
441+
if (reconnection == true && !skipReconnect!) {
452442
reconnect();
453443
}
454444
}
@@ -461,7 +451,7 @@ class Manager extends EventEmitter {
461451
Manager reconnect() {
462452
if (reconnecting || skipReconnect!) return this;
463453

464-
if (backoff!.attempts >= _reconnectionAttempts!) {
454+
if (backoff!.attempts >= reconnectionAttempts!) {
465455
_logger.fine('reconnect failed');
466456
backoff!.reset();
467457
emitAll('reconnect_failed');

lib/src/socket.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class Socket extends EventEmitter {
151151
// event ack callback
152152
if (ack != null) {
153153
_logger.fine('emitting packet with ack id $ids');
154-
acks['${ids}'] = ack;
154+
acks['$ids'] = ack;
155155
packet['id'] = '${ids++}';
156156
}
157157

@@ -186,7 +186,7 @@ class Socket extends EventEmitter {
186186
// if (query?.isNotEmpty == true) {
187187
// packet({'type': CONNECT, 'query': query});
188188
// } else {
189-
packet({'type': CONNECT});
189+
packet({'type': CONNECT});
190190
// }
191191
// }
192192
}
@@ -350,7 +350,7 @@ class Socket extends EventEmitter {
350350
///
351351
/// @api private
352352
void ondisconnect() {
353-
_logger.fine('server disconnect (${nsp})');
353+
_logger.fine('server disconnect ($nsp)');
354354
destroy();
355355
onclose('io server disconnect');
356356
}
@@ -383,7 +383,7 @@ class Socket extends EventEmitter {
383383

384384
Socket disconnect() {
385385
if (connected == true) {
386-
_logger.fine('performing disconnect (${nsp})');
386+
_logger.fine('performing disconnect ($nsp)');
387387
packet({'type': DISCONNECT});
388388
}
389389

pubspec.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: socket_io_client
22
description: Dartlang port of socket.io-client for web, flutter, dartvm to use
3-
version: 2.0.0-beta-nullsafety.0
3+
version: 2.0.0-beta.3-nullsafety.0
44
homepage: https://www.zkoss.org
55
repository: https://github.com/rikulo/socket.io-client-dart
66
issue_tracker: https://github.com/rikulo/socket.io-client-dart/issues
@@ -10,7 +10,8 @@ environment:
1010

1111
dependencies:
1212
logging: '^1.0.0-nullsafety.0'
13-
socket_io_common: '^2.0.0-beta-nullsafety.0'
13+
socket_io_common: '^2.0.0-beta.1-nullsafety.0'
14+
js: '^0.6.3'
1415

1516
dev_dependencies:
1617
test: ">=1.3.0 <2.0.0"

0 commit comments

Comments
 (0)