CoapClient class
Provides convenient methods for accessing CoAP resources. This class provides a fairly high level interface for the majority of simple CoAP requests but because of this is fairly coarsely grained. Much finer control of a request can be achieved by direct construction and manipulation of a CoapRequest itself, however this is more involved, for most cases the API in this class should suffice.
Note that currently a self constructed resource must be prepared by the prepare method in this class BEFORE calling any send methods on the resource.
In most cases a resource can be created outside of the client with the relevant parameters then set in the client.
Constructors
- CoapClient(Uri uri, {InternetAddressType addressType = InternetAddressType.any, InternetAddress? bindAddress, EcdsaKeys? ecdsaKeys, PskCredentialsCallback? pskCredentialsCallback, DefaultCoapConfig? config})
- Instantiates. A supplied request is optional depending on the API call being used. If it is specified it will be prepared and used. Note that the host name part of the URI can be a name or an IP address, in which case it is not resolved.
Properties
- addressType → InternetAddressType
-
Address type used for DNS lookups.
final
- bindAddress → InternetAddress?
-
The client's local socket bind address, if set explicitly
IPv4 default is 0.0.0.0, IPv6 default is 0:0:0:0:0:0:0:0
final
- events → CoapEventBus
-
The internal request/response event stream
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- uri → Uri
-
The client endpoint URI
final
Methods
-
cancel(
CoapRequest request) → void - Cancels a request
-
cancelObserveProactive(
CoapObserveClientRelation relation) → Future< void> - Cancel ongoing observable request
-
cancelObserveReactive(
CoapObserveClientRelation relation) → void - Cancel after the fact
-
close(
) → void - Cancel all ongoing requests
-
delete(
String path, {CoapMediaType? accept, bool confirmable = true, List< Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a DELETE request
-
discover(
{String query = ''}) → Future< Iterable< CoapWebLink> ?> - Discovers remote resources.
-
fetch(
String path, {CoapMediaType? accept, bool confirmable = true, List< Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a FETCH request.
-
get(
String path, {CoapMediaType? accept, bool confirmable = true, List< Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a GET request.
-
iPatch(
String path, {required String payload, CoapMediaType? format, CoapMediaType? accept, bool confirmable = true, List< Uint8Buffer> ? etags, MatchEtags matchEtags = MatchEtags.onMatch, List<Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends an iPATCH request.
-
iPatchBytes(
String path, {required Uint8Buffer payload, CoapMediaType? format, MatchEtags matchEtags = MatchEtags.onMatch, List< Uint8Buffer> ? etags, CoapMediaType? accept, bool confirmable = true, List<Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a iPATCH request with the specified byte payload.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
observe(
CoapRequest request, {int maxRetransmit = 0}) → Future< CoapObserveClientRelation> - Observe
-
patch(
String path, {required String payload, CoapMediaType? format, CoapMediaType? accept, bool confirmable = true, List< Uint8Buffer> ? etags, MatchEtags matchEtags = MatchEtags.onMatch, List<Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a PATCH request.
-
patchBytes(
String path, {required Uint8Buffer payload, CoapMediaType? format, MatchEtags matchEtags = MatchEtags.onMatch, List< Uint8Buffer> ? etags, CoapMediaType? accept, bool confirmable = true, List<Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a PATCH request with the specified byte payload.
-
ping(
) → Future< bool> - Performs a CoAP ping.
-
post(
String path, {required String payload, CoapMediaType? format, CoapMediaType? accept, bool confirmable = true, List< Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a POST request.
-
postBytes(
String path, {required Uint8Buffer payload, CoapMediaType? format, CoapMediaType? accept, bool confirmable = true, List< Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a POST request with the specified byte payload.
-
put(
String path, {required String payload, CoapMediaType? format, CoapMediaType? accept, bool confirmable = true, List< Uint8Buffer> ? etags, MatchEtags matchEtags = MatchEtags.onMatch, List<Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a PUT request.
-
putBytes(
String path, {required Uint8Buffer payload, CoapMediaType? format, MatchEtags matchEtags = MatchEtags.onMatch, List< Uint8Buffer> ? etags, CoapMediaType? accept, bool confirmable = true, List<Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a PUT request with the specified byte payload.
-
send(
CoapRequest request, {CoapMulticastResponseHandler? onMulticastResponse}) → Future< CoapResponse> - Send
-
sendMulticast(
CoapRequest request) → Stream< CoapResponse> -
Sends a
request
and returns a Stream of CoapResponses. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited