public final class RawData extends Object
Connector.
The following meta-data is included:
false)Principal
object.| Modifier and Type | Field and Description |
|---|---|
byte[] |
bytes
The raw message.
|
| Modifier and Type | Method and Description |
|---|---|
InetAddress |
getAddress()
Gets the address.
|
byte[] |
getBytes()
Gets the raw message.
|
EndpointContext |
getEndpointContext()
Gets additional information regarding the context this message has been
received in or should be sent in.
|
InetSocketAddress |
getInetSocketAddress()
Gets the source/destination IP address and port.
|
int |
getPort()
Gets the port.
|
Principal |
getSenderIdentity()
Gets the identity of the sender of the message.
|
int |
getSize()
Gets the length of the serialized message
|
static RawData |
inbound(byte[] data,
EndpointContext peerEndpointContext,
boolean isMulticast)
Instantiates a new raw data for a message received from a peer.
|
boolean |
isMulticast()
Checks if this is a multicast message
|
void |
onConnecting()
Callback, when connector requires to establish a connection.
|
void |
onContextEstablished(EndpointContext context)
Callback, when context gets available.
|
void |
onDtlsRetransmission(int flight)
Callback, when the dtls connector retransmits a handshake flight.
|
void |
onError(Throwable error)
Called, when message was not sent by the connector.
|
void |
onSent()
Callback after message was sent by the connector.
|
static RawData |
outbound(byte[] data,
EndpointContext peerEndpointContext,
MessageCallback callback,
boolean useMulticast)
Instantiates a new raw data for a message to be sent to a peer.
|
public static RawData inbound(byte[] data, EndpointContext peerEndpointContext, boolean isMulticast)
data - the data that is to be sent or has been received.peerEndpointContext - information regarding the context the message
has been received in. The information contained will usually
come from the transport layer, e.g. the ID of the DTLS session
the message has been received in, and can be used to correlate
this message with another (previously sent) message.isMulticast - indicates whether the data has been received as a
multicast message.NullPointerException - if data or address is null.public static RawData outbound(byte[] data, EndpointContext peerEndpointContext, MessageCallback callback, boolean useMulticast)
The given callback handler is notified when the message has been sent by
a Connector. The information contained in the
MessageContext object that is passed in to the handler may
be relevant for matching a response received via a
RawDataChannel to a request sent using this method, e.g.
when using a DTLS based connector the context may contain the DTLS
session ID and epoch number which is required to match a response to a
request as defined in the CoAP specification.
The message context is set via a callback in order to allow
Connector implementations to process (send) messages
asynchronously.
data - the data to send.peerEndpointContext - remote peer's endpoint context to send data.callback - the handler to call when this message has been sent (may
be null).useMulticast - indicates whether the data should be sent using a
multicast message.NullPointerException - if data or peerContext is null.public byte[] getBytes()
public int getSize()
public InetAddress getAddress()
public int getPort()
public boolean isMulticast()
public InetSocketAddress getInetSocketAddress()
public Principal getSenderIdentity()
null if the sender has not been
authenticatedpublic EndpointContext getEndpointContext()
public void onConnecting()
public void onDtlsRetransmission(int flight)
flight - 1 ... 6, number of retransmitted flight.public void onContextEstablished(EndpointContext context)
context - established context to be forwarded to the callback.public void onSent()
public void onError(Throwable error)
error - details for not sending the message. If null,
UnknownError is used to call
MessageCallback.onError(Throwable).Copyright © 2019 Eclipse Foundation. All rights reserved.