new Forwarder(options) → {forwarder}
Forwarder constructor
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | an object with options |
- Source:
Returns:
an NDN Subject
- Type
- forwarder
Methods
-
addConnection(urlOrObject, onFace, onFaceClosed)
-
add a connection
Parameters:
Name Type Description urlOrObject
String | Object Either a url string representing the endpoint protocol, ip/domain, and port (e.g "ws://localhost:8585"), or an object (e.g messageChannel port or RTC datachannel) onFace
function callback function which receives the faceID of the newly constructed Face onFaceClosed
function callback function - Source:
-
addConnectionListener(prefix, maxConnections, onNewFace, onFaceClosed)
-
add a connection listener along a given prefix.
Parameters:
Name Type Description prefix
String the prefix to listen along maxConnections
Number maximum number of simultaneous connections for this prefix onNewFace
function a function called for each new face, containing the numerical faceID onFaceClosed
function a function called every time a face on this prefix is closed - Source:
-
addListener(nameSpace, callback)
-
add a nameSpace Listener to the Forwarder. the listener will be triggered via the same semantics as forwarding entries
Parameters:
Name Type Description nameSpace
String | option the uri of the namespace to listen on, or an options object containing that uri under the .prefix property so far only a boolean '.blocking' property, to tell whether to interupt normal forwarding callback
function - Source:
-
addRegisteredPrefix(prefix, faceID) → {this}
-
add a registered prefix for interest forwarding into the fib
Parameters:
Name Type Description prefix
String the uri encoded prefix for the forwarding entry faceID
Number the numerical faceID of the face to add the prefix to - Source:
Returns:
for chaining- Type
- this
-
handleData(element, the) → {Forwarder}
-
main algorithm for incoming data packets. In order; check and dispatch matching PitEntries, insert into cache, return.
Parameters:
Name Type Description element
Buffer the raw data packet the
faceID numerical faceID that the packet arrived on - Source:
Returns:
for chaining- Type
- Forwarder
-
handleInterest(element, faceID) → {this}
-
handle an incoming interest from the interfaces module
Parameters:
Name Type Description element
Buffer the raw interest packet faceID
Number the Integer faceID of the face which recieved the Interest - Source:
Returns:
for chaining- Type
- this
-
registerPrefix(prefix, faceID) → {this}
-
request a remote forwarder to add a registered prefix for this forwarder
Parameters:
Name Type Description prefix
String the uri encoded prefix for the forwarding entry faceID
Number the numerical faceID of the face to make the request - Source:
Returns:
for chaining- Type
- this
-
removeConnection(faceID) → {this}
-
remove a connection, and purge any registered Prefixes from the FIB
Parameters:
Name Type Description faceID
Number Numerical faceID of the connection to remove - Source:
Returns:
Forwarder for chaining- Type
- this
-
removeListeners(prefix) → {this}
-
Remove ALL listeners on a given namespace (but NOT all prefixes) ie, two listeners on /a/b and one on /a: .removeListeners("/a/b") will remove both on /a/b and leave the one on /a
Parameters:
Name Type Description prefix
String the nameSpace uri to remove listeners on - Source:
Returns:
for chaining- Type
- this
-
requestConnection(prefix, onFace, onFaceClosed)
-
request a connection 'In-band' over NDN; rather than provide an IP/DNS endpoint, provide a NDN prefix, and be connected with any other forwarder that is listening for connections along that prefix
Parameters:
Name Type Description prefix
String the uri encoded prefix to register the connection along onFace
function a callback function called upon face construction, which gets the numerical faceID as the only argument onFaceClosed
function a callback function once the face is closed - Source:
-
setMaxConnections(maximum) → {this}
-
set maximum number of connections for the forwarder (default unset)
Parameters:
Name Type Description maximum
Number the maximum number of simultaneous connections - Source:
Returns:
for chaining- Type
- this
-
unregisterPrefix(prefix, faceID) → {this}
-
remove a registered prefix for a remote face
Parameters:
Name Type Description prefix
String the uri encoded prefix for the forwarding entry faceID
Number the numerical faceID of the face remove the prefix from - Source:
Returns:
for chaining- Type
- this