CoapRequest class

This class describes the functionality of a CoAP Request as a subclass of a CoAP Message. It provides:

  1. operations to answer a request by a response using respond()
  2. different ways to handle incoming responses: receiveResponse() or Response event.

Constructors

CoapRequest(Uri uri, RequestMethod method, {bool confirmable = true, Iterable<int>? payload, CoapMediaType? accept, CoapMediaType? contentFormat})
Initializes a request message. Defaults to confirmable
CoapRequest.delete(Uri uri, {bool confirmable = true, Iterable<int>? payload, CoapMediaType? accept})
Construct a DELETE request.
factory
CoapRequest.fetch(Uri uri, {bool confirmable = true, Iterable<int>? payload, CoapMediaType? contentFormat, CoapMediaType? accept})
Construct a FETCH request.
factory
CoapRequest.fromParsed(Uri uri, RequestMethod method, {required CoapMessageType type, required int id, required Uint8Buffer token, required List<Option<Object?>> options, required Uint8Buffer? payload, required bool hasUnknownCriticalOption, required bool hasFormatError})
CoapRequest.get(Uri uri, {bool confirmable = true, Iterable<int>? payload, CoapMediaType? accept})
Construct a GET request.
factory
CoapRequest.iPatch(Uri uri, {bool confirmable = true, Iterable<int>? payload, CoapMediaType? contentFormat, CoapMediaType? accept})
Construct a iPATCH request.
factory
CoapRequest.patch(Uri uri, {bool confirmable = true, Iterable<int>? payload, CoapMediaType? contentFormat, CoapMediaType? accept})
Construct a PATCH request.
factory
CoapRequest.post(Uri uri, {bool confirmable = true, Iterable<int>? payload, CoapMediaType? contentFormat, CoapMediaType? accept})
Construct a POST request.
factory
CoapRequest.put(Uri uri, {bool confirmable = true, Iterable<int>? payload, CoapMediaType? contentFormat, CoapMediaType? accept})
Construct a PUT request.
factory

Properties

accept CoapMediaType?
Accept
getter/setter pairinherited
acknowledgedHook ↔ HookFunction?
Acknowledged hook for attaching a callback if needed
getter/setter pairinherited
ackTimeout int
The amount of time in milliseconds after which this message will time out. A value of 0 indicates that the time should be decided automatically from the configuration. The default value is 0.
getter/setter pairinherited
bindAddress InternetAddress?
Bind address if not using the default
getter/setter pairinherited
block1 CoapBlockOption?
Block 1
getter/setter pairinherited
block2 CoapBlockOption?
Block 2
getter/setter pairinherited
code CoapCode
The code of this CoAP message.
finalinherited
codeString String
The codestring
no setterinherited
contentFormat CoapMediaType?
The content-format of this CoAP message, Same as ContentType, only another name.
getter/setter pairinherited
contentType CoapMediaType?
Content type
getter/setter pairinherited
destination InternetAddress?
The destination endpoint.
getter/setter pairinherited
duplicate bool
Indicates whether this message is a duplicate.
getter/setter pairinherited
endpoint ↔ Endpoint?
The endpoint for this request
getter/setter pair
etags List<ETagOption>
Etags
no setterinherited
eventBus ↔ CoapEventBus?
getter/setter pairinherited
hasFormatError bool
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
hasUnknownCriticalOption bool
getter/setter pairinherited
id int?
The ID of this CoAP message.
getter/setter pairinherited
ifMatches List<IfMatchOption>
If-Matches.
no setterinherited
ifNoneMatches List<IfNoneMatchOption>
If-None Matches.
no setterinherited
isAcknowledged bool
Indicates whether this message has been acknowledged.
getter/setter pairinherited
isActive bool
Returns true if this CoapMessage has neither timed out nor has been canceled.
no setterinherited
isCancelled bool
Indicates whether this message has been cancelled.
getter/setter pairinherited
isEmpty bool
Gets a value that indicates whether this CoAP message is an empty message.
no setterinherited
isMulticast bool
Indicates whether this request is a multicast request or not.
no setter
isRejected bool
Indicates whether this message has been rejected.
getter/setter pairinherited
isRequest bool
Gets a value that indicates whether this CoAP message is a request message.
no setterinherited
isResponse bool
Gets a value that indicates whether this CoAP message is a response message.
no setterinherited
isTimedOut bool
Indicates whether this message has been timed out.
getter/setter pairinherited
maxAge int?
The max-age of this CoAP message.
getter/setter pairinherited
maxRetransmit int
The max times this message should be retransmitted if no ACK received. A value of 0 means that the CoapConstants.maxRetransmit time shoud be taken into account, while a negative means NO retransmission. The default value is 0.
getter/setter pairinherited
method RequestMethod
The request method(code)
final
namespace String?
no setterinherited
needsRejection bool
Indicates if this message needs to be rejected as specified in RFC 7252, section 5.4.1.
no setterinherited
observe int?
Observe
getter/setter pairinherited
optionsLength int
no setterinherited
payload → Uint8Buffer
The payload of this CoAP message.
finalinherited
payloadSize int
The size of the payload of this CoAP message.
no setterinherited
payloadString String
The payload of this CoAP message in string representation.
no setterinherited
proxyScheme String?
Proxy scheme
getter/setter pairinherited
proxyUri Uri?
Proxy uri
getter/setter pairinherited
retransmits int
The current number of retransmits
no setterinherited
retransmittingHook ↔ HookFunction?
Retransmit hook function
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size1 int?
Size 1
getter/setter pairinherited
size2 int?
Size 2
getter/setter pairinherited
source InternetAddress?
The source endpoint.
getter/setter pairinherited
timedOutHook ↔ HookFunction?
Timed out hook function for attaching a callback if needed
getter/setter pairinherited
timestamp DateTime?
The timestamp when this message has been received or sent, or null if neither has happened yet.
getter/setter pairinherited
token ↔ Uint8Buffer?
The 0-8 byte token.
getter/setter pairinherited
tokenString String
As a string
no setterinherited
type CoapMessageType
The type of this CoAP message.
getter/setter pairinherited-setter
uri Uri
Specifies the target resource of a request to a CoAP origin server.
getter/setter pair

Methods

addEtag(ETagOption option) → void
Adds an ETag option
inherited
addETagOpaque(Uint8Buffer opaque) → void
Add an opaque ETag
inherited
addIfMatch(String etag) → void
Add an if match option
inherited
addIfMatchOpaque(Uint8Buffer opaque) → void
Add an opaque if match
inherited
addOption(Option<Object?> option) → void
Adds an option to the list of options of this CoapMessage.
inherited
addOptions(Iterable<Option<Object?>> options) → void
Adds options to the list of options of this CoAP message.
inherited
clearETags() → void
Clear the E tags
inherited
clearIfMatches() → void
Clear the if matches
inherited
clearOptions() → void
Clear all options
inherited
containsETagOpaque(Uint8Buffer opaque) bool
Contains an opaque E-tag
inherited
copyEventHandler(CoapMessage msg) → void
Copy an event handler
inherited
fireRetransmitting() → void
Fire retransmitting event
inherited
getAllOptions() List<Option<Object?>>
Gets a list of all options.
getFirstOption<T extends Option<Object?>>() → T?
Returns the first option of the specified type, or null
inherited
getOptions<T extends Option<Object?>>() List<T>
Gets all options of the given type.
inherited
hasOption<T extends Option<Object?>>() bool
Checks if this CoAP message has options of the specified option type. Returns true if options of the specified type exists.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeEtag(ETagOption option) bool
Remove an ETag, true indicates success
inherited
removeETagOpaque(Uint8Buffer opaque) → void
Remove an opaque ETag
inherited
removeIfMatch(IfMatchOption option) → void
Remove an if match option
inherited
removeIfMatchOpaque(Uint8Buffer opaque) → void
Remove an opaque if match
inherited
removeIfNoneMatch(IfNoneMatchOption option) → void
Remove an if none match option
inherited
removeOption(Option<Object?> option) bool
Remove a specific option, returns true if the option has been removed.
inherited
removeOptions<T extends Option<Object?>>() → void
Removes all options of the given type from this CoAP message.
inherited
removeOptionWhere(bool test(Option<Object?>)) → void
Removes all options for which the given test function returns true.
inherited
setBlock1(BlockSize szx, int num, {required bool m}) → void
Block 1
inherited
setBlock2(BlockSize szx, int num, {required bool m}) → void
Block 2
inherited
setOption<T extends Option<Object?>>(T option) → void
Sets an option, removing all others of the option type
inherited
setOptions(Iterable<Option<Object?>> options) → void
Sets all options with the specified option type, removing all others of the same type.
inherited
toString() String
A string representation of this object.
toTcpPayload() → Uint8Buffer
Serializes this CoAP message into the TCP message format.
inherited
toUdpPayload() → Uint8Buffer
Serializes this CoAP message into the UDP message format.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited