new MicroForwarderTransport()
A MicroForwarderTransport extends Transport to connect to the browser's
micro forwarder service. This assumes that the MicroForwarder extensions has
been installed.
Methods
(static) ConnectionInfo()
Create a new MicroForwarderTransport.ConnectionInfo which extends
Transport.ConnectionInfo to hold info for the micro forwarer connection.
connect(connectionInfo, elementListener, onopenCallback, onclosedCallback)
Connect to the micro forwarder according to the info in connectionInfo.
Listen on the connection to read an entire packet element and call
elementListener.onReceivedElement(element). However, if the received object
type field is not "Buffer" then just call this.onReceivedObject(obj).
Parameters:
Name | Type | Description |
---|---|---|
connectionInfo |
MicroForwarderTransport.ConnectionInfo | |
elementListener |
object | The elementListener with function onReceivedElement which must remain valid during the life of this object. |
onopenCallback |
function | Once connected, call onopenCallback(). |
onclosedCallback |
function | (optional) If the connection is closed by the remote host, call onclosedCallback(). If omitted or null, don't call it. |
isLocal(connectionInfo, onResult, onError)
Determine whether this transport connecting according to connectionInfo is to
a node on the current machine. Unix transports are always local.
Parameters:
Name | Type | Description |
---|---|---|
connectionInfo |
MicroForwarderTransport.ConnectionInfo | This is ignored. |
onResult |
function | This calls onResult(true) because micro forwarder transports are always local. |
onError |
function | This is ignored. |
send(buffer)
Send the buffer over the connection created by connect.
Parameters:
Name | Type | Description |
---|---|---|
buffer |
Buffer | The bytes to send. |
sendObject(obj)
Send the JavaScript over the connection created by connect.
Parameters:
Name | Type | Description |
---|---|---|
obj |
object | The object to send. It should have a field "type". If "type" is "Buffer" then it is processed like an NDN packet. |
setOnReceivedObject(onReceivedObject)
Set the onReceivedObject callback, replacing any previous callback.
Parameters:
Name | Type | Description |
---|---|---|
onReceivedObject |
function | (optional) If supplied and the received object type field is not "Buffer" then just call this.onReceivedObject(obj). If this is null, then don't call it. |