Skip to content

Commit

Permalink
bump 1.0.0 version for sound null safety.
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen committed Apr 28, 2021
1 parent 6b13a19 commit 154798c
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 84 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.0.0-nullsafety.0
## 1.0.0

**New Feature:**

Expand Down
17 changes: 9 additions & 8 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ analyzer:
# Lint rules and documentation, see http://dart-lang.github.io/linter/lints
linter:
rules:
- cancel_subscriptions
- close_sinks
- hash_and_equals
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- test_types_in_equals
- unrelated_type_equality_checks
- valid_regexps
unsafe_html: false
cancel_subscriptions: true
close_sinks: true
hash_and_equals: true
iterable_contains_unrelated_type: true
list_remove_unrelated_type: true
test_types_in_equals: true
unrelated_type_equality_checks: true
valid_regexps: true
2 changes: 1 addition & 1 deletion lib/src/engine/socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ class Socket extends EventEmitter {
break;
}
} else {
_logger.fine('packet received with socket readyState "${readyState}"');
_logger.fine('packet received with socket readyState "$readyState"');
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/engine/transport/jsonp_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class JSONPTransport extends PollingTransport {
if (form == null) {
var form = document.createElement('form') as FormElement;
var area = document.createElement('textarea') as TextAreaElement;
var id = iframeId = 'eio_iframe_${index}';
var id = iframeId = 'eio_iframe_$index';

form.className = 'socketio';
form.style.position = 'absolute';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/engine/transport/polling_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ abstract class PollingTransport extends Transport {
if ('open' == readyState) {
poll();
} else {
_logger.fine('ignoring poll - transport state "${readyState}"');
_logger.fine('ignoring poll - transport state "$readyState"');
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/engine/transport/xhr_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Request extends EventEmitter {
var self = this;

try {
_logger.fine('xhr open ${method}: ${uri}');
_logger.fine('xhr open $method: $uri');
xhr.open(method, uri, async: async);

try {
Expand Down Expand Up @@ -233,7 +233,7 @@ class Request extends EventEmitter {
});
/*}*/

_logger.fine('xhr data ${data}');
_logger.fine('xhr data $data');
xhr.send(data);
} catch (e) {
// Need to defer since .create() is called directly fhrom the constructor
Expand Down
79 changes: 31 additions & 48 deletions lib/src/manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,34 @@ class Manager extends EventEmitter {
List subs = [];
late Map options;

bool? _reconnection;
num? _reconnectionAttempts;
num? _reconnectionDelay;
///
/// Sets the `reconnection` config.
///
/// @param {Boolean} true/false if it should automatically reconnect
/// @return {Manager} self or value
/// @api public
///
bool? reconnection;

///
/// Sets the reconnection attempts config.
///
/// @param {Number} max reconnection attempts before giving up
/// @return {Manager} self or value
/// @api public
///
num? reconnectionAttempts;
num? reconnectionDelay;
num? _randomizationFactor;
num? _reconnectionDelayMax;
num? _timeout;

///
/// Sets the connection timeout. `false` to disable
///
/// @return {Manager} self or value
/// @api public
///
num? timeout;
_Backoff? backoff;
String readyState = 'closed';
late String uri;
Expand Down Expand Up @@ -103,36 +125,6 @@ class Manager extends EventEmitter {
return (nsp.isEmpty ? '' : (nsp + '#')) + (engine.id ?? '');
}

///
/// Sets the `reconnection` config.
///
/// @param {Boolean} true/false if it should automatically reconnect
/// @return {Manager} self or value
/// @api public
///
bool? get reconnection => _reconnection;
set reconnection(bool? v) => _reconnection = v;

///
/// Sets the reconnection attempts config.
///
/// @param {Number} max reconnection attempts before giving up
/// @return {Manager} self or value
/// @api public
///
num? get reconnectionAttempts => _reconnectionAttempts;
set reconnectionAttempts(num? v) => _reconnectionAttempts = v;

///
/// Sets the delay between reconnections.
///
/// @param {Number} delay
/// @return {Manager} self or value
/// @api public
///
num? get reconnectionDelay => _reconnectionDelay;
set reconnectionDelay(num? v) => _reconnectionDelay = v;

num? get randomizationFactor => _randomizationFactor;
set randomizationFactor(num? v) {
_randomizationFactor = v;
Expand All @@ -152,15 +144,6 @@ class Manager extends EventEmitter {
backoff?.max = v;
}

///
/// Sets the connection timeout. `false` to disable
///
/// @return {Manager} self or value
/// @api public
///
num? get timeout => _timeout;
set timeout(num? v) => _timeout = v;

///
/// Starts trying to reconnect if reconnection is enabled and we have not
/// started reconnecting yet
Expand All @@ -169,7 +152,7 @@ class Manager extends EventEmitter {
///
void maybeReconnectOnOpen() {
// Only try to reconnect if it's the first time we're connecting
if (!reconnecting && _reconnection == true && backoff!.attempts == 0) {
if (!reconnecting && reconnection == true && backoff!.attempts == 0) {
// keeps reconnection from firing twice for the same reconnection loop
reconnect();
}
Expand Down Expand Up @@ -216,8 +199,8 @@ class Manager extends EventEmitter {
});

// emit `connect_timeout`
if (_timeout != null) {
var timeout = _timeout!;
var timeout = this.timeout;
if (timeout != null) {
_logger.fine('connect attempt will timeout after $timeout');

// set timer
Expand Down Expand Up @@ -450,7 +433,7 @@ class Manager extends EventEmitter {
readyState = 'closed';
emit('close', error['reason']);

if (_reconnection == true && !skipReconnect!) {
if (reconnection == true && !skipReconnect!) {
reconnect();
}
}
Expand All @@ -463,7 +446,7 @@ class Manager extends EventEmitter {
Manager reconnect() {
if (reconnecting || skipReconnect!) return this;

if (backoff!.attempts >= _reconnectionAttempts!) {
if (backoff!.attempts >= reconnectionAttempts!) {
_logger.fine('reconnect failed');
backoff!.reset();
emitAll('reconnect_failed');
Expand Down
6 changes: 3 additions & 3 deletions lib/src/socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Socket extends EventEmitter {
// event ack callback
if (ack != null) {
_logger.fine('emitting packet with ack id $ids');
acks['${ids}'] = ack;
acks['$ids'] = ack;
packet['id'] = '${ids++}';
}

Expand Down Expand Up @@ -354,7 +354,7 @@ class Socket extends EventEmitter {
///
/// @api private
void ondisconnect() {
_logger.fine('server disconnect (${nsp})');
_logger.fine('server disconnect ($nsp)');
destroy();
onclose('io server disconnect');
}
Expand Down Expand Up @@ -387,7 +387,7 @@ class Socket extends EventEmitter {

Socket disconnect() {
if (connected == true) {
_logger.fine('performing disconnect (${nsp})');
_logger.fine('performing disconnect ($nsp)');
packet({'type': DISCONNECT});
}

Expand Down
12 changes: 5 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
name: socket_io_client
description: Dartlang port of socket.io-client for web, flutter, dartvm to use
version: 1.0.0-nullsafety.0
version: 1.0.0
homepage: https://www.zkoss.org
repository: https://github.com/rikulo/socket.io-client-dart
issue_tracker: https://github.com/rikulo/socket.io-client-dart/issues

environment:
sdk: '>=2.12.0-0 <3.0.0'
sdk: '>=2.12.0 <3.0.0'

dependencies:
socket_io_common: '^1.0.0-nullsafety.1'
js: '^0.6.3-nullsafety.3'
logging: '^1.0.0-nullsafety.0'
socket_io_common: '^1.0.0'
js: '^0.6.3'
logging: '^1.0.1'

dependency_overrides:
logging: '^1.0.0-nullsafety.0'

dev_dependencies:
socket_io: any
Expand Down
22 changes: 10 additions & 12 deletions test/server.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/**
* server.dart
*
* Purpose:
*
* Description:
*
* History:
* 26/07/2017, Created by jumperchen
*
* Copyright (C) 2017 Potix Corporation. All Rights Reserved.
*/
/// server.dart
///
/// Purpose:
///
/// Description:
///
/// History:
/// 26/07/2017, Created by jumperchen
///
/// Copyright (C) 2017 Potix Corporation. All Rights Reserved.
import 'package:socket_io/socket_io.dart';

void main() {
Expand Down

0 comments on commit 154798c

Please sign in to comment.