diff --git a/analysis_options.yaml b/analysis_options.yaml index 9045a68f..5f235a2a 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -31,7 +31,7 @@ linter: - avoid_catching_errors - avoid_classes_with_only_static_members - avoid_double_and_int_checks - #- avoid_dynamic_calls + - avoid_dynamic_calls - avoid_empty_else - avoid_equals_and_hash_code_on_mutable_classes - avoid_escaping_inner_quotes @@ -98,6 +98,7 @@ linter: - no_default_cases - no_duplicate_case_values - no_logic_in_create_state + - no_runtimeType_toString - non_constant_identifier_names - noop_primitive_operations - null_check_on_nullable_type_parameter diff --git a/lib/src/coap_client.dart b/lib/src/coap_client.dart index 8c9eb64c..c8c4edf3 100644 --- a/lib/src/coap_client.dart +++ b/lib/src/coap_client.dart @@ -516,7 +516,8 @@ class CoapClient { request ..observe = ObserveRegistration.register.value ..maxRetransmit = maxRetransmit; - final responseStream = _sendWithStreamResponse(request).asBroadcastStream(); + final responseStream = _sendWithStreamResponse(request) + .asBroadcastStream(onCancel: (final sub) => sub.cancel()); final relation = CoapObserveClientRelation(request, responseStream); final resp = await _waitForResponse(request, responseStream); if (!resp.hasOption()) { @@ -543,7 +544,8 @@ class CoapClient { final CoapRequest request, { final CoapMulticastResponseHandler? onMulticastResponse, }) async { - final responseStream = _sendWithStreamResponse(request).asBroadcastStream(); + final responseStream = _sendWithStreamResponse(request) + .asBroadcastStream(onCancel: (final sub) => sub.cancel()); if (request.isMulticast) { if (onMulticastResponse == null) { throw ArgumentError('Missing onMulticastResponse argument'); diff --git a/lib/src/event/coap_event_bus.dart b/lib/src/event/coap_event_bus.dart index ee911a19..1eff0d68 100644 --- a/lib/src/event/coap_event_bus.dart +++ b/lib/src/event/coap_event_bus.dart @@ -25,7 +25,7 @@ abstract class CoapMessageEvent { CoapMessage msg; @override - String toString() => '$runtimeType: $msg'; + String toString() => 'CoapMessageEvent: $msg'; } abstract class CoapRequestEvent { @@ -35,7 +35,7 @@ abstract class CoapRequestEvent { CoapRequest req; @override - String toString() => '$runtimeType: $req'; + String toString() => 'CoapRequestEvent: $req'; } abstract class CoapResponseEvent { @@ -45,7 +45,7 @@ abstract class CoapResponseEvent { CoapResponse resp; @override - String toString() => '$runtimeType: $resp'; + String toString() => 'CoapResponseEvent: $resp'; } abstract class CoapExchangeEvent { @@ -56,7 +56,7 @@ abstract class CoapExchangeEvent { @override String toString() => - '$runtimeType:\nExchange for request ${exchange.request.id} ' + 'CoapExchangeEvent:\nExchange for request ${exchange.request.id} ' "(token '${exchange.request.tokenString}')"; } @@ -158,7 +158,8 @@ class CoapMessageReceivedEvent { InternetAddress address; @override - String toString() => '$runtimeType:\n$coapMessage from ${address.address}'; + String toString() => + 'CoapMessageReceivedEvent:\n$coapMessage from ${address.address}'; } class CoapSocketInitEvent { @@ -166,7 +167,7 @@ class CoapSocketInitEvent { CoapSocketInitEvent(); @override - String toString() => '$runtimeType:\nSocket attempting to initialize'; + String toString() => 'CoapSocketInitEvent:\nSocket attempting to initialize'; } class CoapSocketErrorEvent { @@ -180,7 +181,7 @@ class CoapSocketErrorEvent { StackTrace stackTrace; @override - String toString() => '$runtimeType:\n$error\n$stackTrace'; + String toString() => 'CoapSocketErrorEvent:\n$error\n$stackTrace'; } /// Event bus class diff --git a/lib/src/exceptions/coap_request_exception.dart b/lib/src/exceptions/coap_request_exception.dart index 3115df4b..25de4d16 100644 --- a/lib/src/exceptions/coap_request_exception.dart +++ b/lib/src/exceptions/coap_request_exception.dart @@ -12,7 +12,7 @@ abstract class CoapRequestException implements Exception { CoapRequestException(); @override - String toString() => '$runtimeType: $failReason'; + String toString() => 'CoapRequestException: $failReason'; } /// This [Exception] is thrown when a CoAP request has timed out. diff --git a/lib/src/network/coap_inetwork.dart b/lib/src/network/coap_inetwork.dart index e1e203dd..ed67c66a 100644 --- a/lib/src/network/coap_inetwork.dart +++ b/lib/src/network/coap_inetwork.dart @@ -23,8 +23,8 @@ class UnsupportedProtocolException implements Exception { UnsupportedProtocolException(this.uriScheme); @override - String toString() => - '$runtimeType: Unsupported URI scheme $uriScheme encountered.'; + String toString() => 'UnsupportedProtocolException: ' + 'Unsupported URI scheme $uriScheme encountered.'; } /// Abstract networking class, allows different implementations for diff --git a/lib/src/option/coap_block_option.dart b/lib/src/option/coap_block_option.dart index 548d51ed..56d54637 100644 --- a/lib/src/option/coap_block_option.dart +++ b/lib/src/option/coap_block_option.dart @@ -87,7 +87,7 @@ enum BlockOptionType { abstract class CoapBlockOption extends IntegerOption with OscoreOptionClassE, OscoreOptionClassU { String get _szxErrorMessage => - 'Encountered reserved SZX value 7 in $runtimeType.'; + 'Encountered reserved SZX value 7 in CoapBlockOption.'; /// Base construction CoapBlockOption( diff --git a/lib/src/option/coap_option_type.dart b/lib/src/option/coap_option_type.dart index 860e1580..cfbea9f7 100644 --- a/lib/src/option/coap_option_type.dart +++ b/lib/src/option/coap_option_type.dart @@ -29,7 +29,7 @@ abstract class UnknownOptionException implements Exception { UnknownOptionException(this.optionNumber, this.errorMessage); @override - String toString() => '$runtimeType: $errorMessage'; + String toString() => 'UnknownOptionException: $errorMessage'; } /// [Exception] that is thrown when an unknown elective CoapOption number is diff --git a/lib/src/stack/layers/reliability.dart b/lib/src/stack/layers/reliability.dart index c7f91d65..ba5d3d9f 100644 --- a/lib/src/stack/layers/reliability.dart +++ b/lib/src/stack/layers/reliability.dart @@ -248,8 +248,7 @@ class _TransmissionContext { // Do not retransmit a message if it has been acknowledged, // rejected, canceled or already been retransmitted for the maximum // number of times. - if (!_message.isRejected && - _message.isActive && + if (_message.isActive && failedTransmissionCount <= (_message.maxRetransmit != 0 ? _message.maxRetransmit diff --git a/pubspec.yaml b/pubspec.yaml index 48134f98..59759a6b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,22 +11,22 @@ environment: sdk: '>=3.0.0 <4.0.0' dependencies: - build: ^2.4.0 - collection: ^1.17.2 + build: ^2.4.1 + collection: ^1.18.0 convert: ^3.1.1 dtls2: ^0.16.0 event_bus: ^2.0.0 - meta: ^1.9.0 - path: ^1.8.3 + meta: ^1.12.0 + path: ^1.9.0 string_scanner: ^1.2.0 synchronized: ^3.1.0 typed_data: ^1.3.2 yaml: ^3.1.2 dev_dependencies: - build_runner: ^2.4.7 + build_runner: ^2.4.8 lints: ^3.0.0 - test: ^1.25.0 + test: ^1.25.2 topics: - iot