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 baseUri, {InternetAddressType addressType = InternetAddressType.any, InternetAddress? bindAddress, 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
- baseUri → Uri
-
The client endpoint URI
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
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(
Uri uri, {CoapMediaType? accept, bool confirmable = true, List< Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a DELETE request
-
discover(
{Uri? uri}) → Future< Iterable< CoapWebLink> ?> - Discovers remote resources.
-
fetch(
Uri uri, {required String payload, CoapMediaType? accept, CoapMediaType? format, bool confirmable = true, List< Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a FETCH request.
-
fetchBytes(
Uri uri, {required Iterable< int> payload, CoapMediaType? accept, CoapMediaType? format, bool confirmable = true, List<Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a FETCH request with the specified byte payload.
-
get(
Uri uri, {CoapMediaType? accept, bool confirmable = true, List< Option< ? options, bool earlyBlock2Negotiation = false, int maxRetransmit = 0, CoapMulticastResponseHandler? onMulticastResponse}) → Future<Object?> >CoapResponse> - Sends a GET request.
-
iPatch(
Uri uri, {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(
Uri uri, {required Iterable< int> 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(
Uri uri, {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(
Uri uri, {required Iterable< int> 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(
Uri uri, {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(
Uri uri, {required Iterable< int> 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(
Uri uri, {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(
Uri uri, {required Iterable< int> 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 ofCoapResponse
s. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited