Skip to content

Commit da41054

Browse files
committed
feat: remove CoAP subprotocol
1 parent 4148ad5 commit da41054

File tree

4 files changed

+4
-60
lines changed

4 files changed

+4
-60
lines changed

lib/src/binding_coap/coap_client.dart

+3-11
Original file line numberDiff line numberDiff line change
@@ -435,22 +435,14 @@ final class CoapClient extends ProtocolClient
435435
accept: form.accept,
436436
);
437437

438-
final subprotocol = form.coapSubprotocol ?? operationType.subprotocol;
439-
440438
final coapClient = coap.CoapClient(
441439
form.resolvedHref,
442440
config: _InternalCoapConfig(_coapConfig ?? const CoapConfig()),
443441
);
444442

445-
if (subprotocol == CoapSubprotocol.observe) {
446-
final observeClientRelation = await coapClient.observe(request);
447-
observeClientRelation.listen(handleResponse);
448-
return CoapSubscription(coapClient, observeClientRelation, complete);
449-
}
450-
451-
final response = await coapClient.send(request);
452-
handleResponse(response);
453-
return CoapSubscription(coapClient, null, complete);
443+
final observeClientRelation = await coapClient.observe(request);
444+
observeClientRelation.listen(handleResponse);
445+
return CoapSubscription(coapClient, observeClientRelation, complete);
454446
}
455447

456448
@override

lib/src/binding_coap/coap_client_factory.dart

+1-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import "../../core.dart";
88

99
import "coap_client.dart";
1010
import "coap_config.dart";
11-
import "coap_definitions.dart";
1211

1312
/// A [ProtocolClientFactory] that produces CoAP clients.
1413
final class CoapClientFactory implements ProtocolClientFactory {
@@ -56,11 +55,6 @@ final class CoapClientFactory implements ProtocolClientFactory {
5655
OperationType.unsubscribeevent,
5756
];
5857

59-
if (observeOperations.contains(operationType)) {
60-
return CoapSubprotocol.tryParse(subprotocol ?? "") ==
61-
CoapSubprotocol.observe;
62-
}
63-
64-
return subprotocol == null;
58+
return observeOperations.contains(operationType);
6559
}
6660
}

lib/src/binding_coap/coap_definitions.dart

-17
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,3 @@ enum CoapRequestMethod {
5050
static CoapRequestMethod? fromString(String stringValue) =>
5151
_registry[stringValue];
5252
}
53-
54-
/// Enumeration of available CoAP subprotocols.
55-
enum CoapSubprotocol {
56-
/// Subprotocol for observing CoAP resources.
57-
observe,
58-
;
59-
60-
/// Tries to match the given [subprotocol] string to one of the known
61-
/// [CoapSubprotocol.values].
62-
static CoapSubprotocol? tryParse(String subprotocol) {
63-
if (subprotocol == "cov:observe") {
64-
return CoapSubprotocol.observe;
65-
}
66-
67-
return null;
68-
}
69-
}

lib/src/binding_coap/coap_extensions.dart

-25
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ extension CoapFormExtension on AugmentedForm {
3636
bool get usesAutoScheme =>
3737
securityDefinitions.whereType<AutoSecurityScheme>().isNotEmpty;
3838

39-
/// Get the [CoapSubprotocol] for this [AugmentedForm], if one is set.
40-
CoapSubprotocol? get coapSubprotocol {
41-
if (subprotocol == coapPrefixMapping.expandCurieString("observe")) {
42-
return CoapSubprotocol.observe;
43-
}
44-
45-
return null;
46-
}
47-
4839
/// The Content-Format for CoAP request and response payloads.
4940
CoapMediaType get contentFormat {
5041
final formDefinition = _obtainVocabularyTerm<int>("contentFormat");
@@ -160,22 +151,6 @@ extension OperationTypeExtension on OperationType {
160151
return CoapRequestMethod.get;
161152
}
162153
}
163-
164-
/// Determines the [CoapSubprotocol] (if any) for this [OperationType].
165-
///
166-
/// The only supported subprotocol at the moment is `observe`.
167-
CoapSubprotocol? get subprotocol {
168-
if ([
169-
OperationType.subscribeevent,
170-
OperationType.unsubscribeevent,
171-
OperationType.observeproperty,
172-
OperationType.unobserveproperty,
173-
].contains(this)) {
174-
return CoapSubprotocol.observe;
175-
}
176-
177-
return null;
178-
}
179154
}
180155

181156
/// Extension for easily extracting the [content] from a [CoapResponse].

0 commit comments

Comments
 (0)