net.named_data.jndn
public class Node extends Object implements ElementListener
| Constructor and Description |
|---|
Node(Transport transport,
Transport.ConnectionInfo connectionInfo)
Create a new Node for communication with an NDN hub with the given
Transport object and connectionInfo.
|
| Modifier and Type | Method and Description |
|---|---|
long |
expressInterest(Interest interest,
OnData onData,
OnTimeout onTimeout,
WireFormat wireFormat)
Send the Interest through the transport, read the entire response and call
onData(interest, data).
|
Transport.ConnectionInfo |
getConnectionInfo() |
static int |
getMaxNdnPacketSize()
Get the practical limit of the size of a network-layer packet.
|
Transport |
getTransport() |
boolean |
isLocal()
Check if the face is local based on the current connection through the
Transport; some Transport may cause network IO (e.g.
|
void |
onReceivedElement(ByteBuffer element)
This is called when an entire binary XML element is received.
|
void |
processEvents()
Process any packets to receive and call callbacks such as onData,
onInterest or onTimeout.
|
void |
putData(Data data,
WireFormat wireFormat)
The OnInterestCallback calls this to put a Data packet which
satisfies an Interest.
|
long |
registerPrefix(Name prefix,
OnInterestCallback onInterest,
OnRegisterFailed onRegisterFailed,
ForwardingFlags flags,
WireFormat wireFormat,
KeyChain commandKeyChain,
Name commandCertificateName,
Face face)
Register prefix with the connected NDN hub and call onInterest when a
matching interest is received.
|
void |
removePendingInterest(long pendingInterestId)
Remove the pending interest entry with the pendingInterestId from the
pending interest table.
|
void |
removeRegisteredPrefix(long registeredPrefixId)
Remove the registered prefix entry with the registeredPrefixId from the
registered prefix table.
|
void |
send(ByteBuffer encoding)
Send the encoded packet out through the transport.
|
long |
setInterestFilter(InterestFilter filter,
OnInterestCallback onInterest,
Face face)
Add an entry to the local interest filter table to call the onInterest
callback for a matching incoming Interest.
|
void |
shutdown()
Shut down by closing the transport
|
void |
unsetInterestFilter(long interestFilterId)
Remove the interest filter entry which has the interestFilterId from the
interest filter table.
|
public Node(Transport transport, Transport.ConnectionInfo connectionInfo)
transport - A Transport object used for communication.connectionInfo - A Transport.ConnectionInfo to be used to connect to
the transport.public final long expressInterest(Interest interest, OnData onData, OnTimeout onTimeout, WireFormat wireFormat) throws IOException
interest - The Interest to send. This copies the Interest.onData - This calls onData.onData when a matching data packet is
received.onTimeout - This calls onTimeout.onTimeout if the interest times out.
If onTimeout is null, this does not use it.wireFormat - A WireFormat object used to encode the message.IOException - For I/O error in sending the interest.Error - If the encoded interest size exceeds getMaxNdnPacketSize().public final void removePendingInterest(long pendingInterestId)
pendingInterestId - The ID returned from expressInterest.public final long registerPrefix(Name prefix, OnInterestCallback onInterest, OnRegisterFailed onRegisterFailed, ForwardingFlags flags, WireFormat wireFormat, KeyChain commandKeyChain, Name commandCertificateName, Face face) throws IOException, SecurityException
prefix - A Name for the prefix to register. This copies the Name.onInterest - (optional) If not null, this creates an interest filter
from prefix so that when an Interest is received which matches the filter,
this calls
onInterest.onInterest(prefix, interest, face, interestFilterId, filter).
If onInterest is null, it is ignored and you must call setInterestFilter.onRegisterFailed - This calls onRegisterFailed.onRegisterFailed(prefix)
if failed to retrieve the connected hub's ID or failed to register the
prefix.flags - The flags for finer control of which interests are forwarded
to the application.wireFormat - A WireFormat object used to encode the message.commandKeyChain - The KeyChain object for signing interests. If null,
assume we are connected to a legacy NDNx forwarder.commandCertificateName - The certificate name for signing interests.face - The face which is passed to the onInterest callback. If
onInterest is null, this is ignored.IOException - For I/O error in sending the registration request.SecurityException - If signing a command interest for NFD and cannot
find the private key for the certificateName.public final void removeRegisteredPrefix(long registeredPrefixId)
registeredPrefixId - The ID returned from registerPrefix.public final long setInterestFilter(InterestFilter filter, OnInterestCallback onInterest, Face face)
filter - The InterestFilter with a prefix and optional regex filter
used to match the name of an incoming Interest. This makes a copy of filter.onInterest - When an Interest is received which matches the filter,
this calls
onInterest.onInterest(prefix, interest, face, interestFilterId, filter).face - The face which is passed to the onInterest callback.public final void unsetInterestFilter(long interestFilterId)
interestFilterId - The ID returned from setInterestFilter.public final void putData(Data data, WireFormat wireFormat) throws IOException
data - The Data packet which satisfies the interest.wireFormat - A WireFormat object used to encode the Data packet.Error - If the encoded Data packet size exceeds getMaxNdnPacketSize().IOExceptionpublic final void send(ByteBuffer encoding) throws IOException
encoding - The array of bytes for the encoded packet to send. This
reads from position() to limit(), but does not change the position.Error - If the encoded packet size exceeds getMaxNdnPacketSize().IOExceptionpublic final void processEvents()
throws IOException,
EncodingException
IOExceptionEncodingExceptionpublic final Transport getTransport()
public final Transport.ConnectionInfo getConnectionInfo()
public final void onReceivedElement(ByteBuffer element) throws EncodingException
ElementListeneronReceivedElement in interface ElementListenerelement - The binary XML element. This buffer is only valid during
this call. If you need the data
later, you must copy.EncodingExceptionpublic final boolean isLocal()
throws IOException
IOExceptionpublic final void shutdown()
public static int getMaxNdnPacketSize()
Copyright © 2015. All rights reserved.