Class: XpcomTransport

XpcomTransport

new XpcomTransport()

Source:

Methods

(static) ConnectionInfo(host, port)

Create a new XpcomTransport.ConnectionInfo which extends Transport.ConnectionInfo to hold the host and port info for the XPCOM connection.
Parameters:
Name Type Description
host string The host for the connection.
port number (optional) The port number for the connection. If omitted, use 6363.
Source:

connect(connectionInfo, elementListener, onopenCallback, onclosedCallback) → {undefined}

Connect to a TCP socket through Xpcom according to the info in connectionInfo. Listen on the port to read an entire packet element and call elementListener.onReceivedElement(element). Note: this connect method previously took a Face object which is deprecated and renamed as the method connectByFace.
Parameters:
Name Type Description
connectionInfo XpcomTransport.ConnectionInfo A XpcomTransport.ConnectionInfo with the host and port.
elementListener object The elementListener with function onReceivedElement which must remain valid during the life of this object.
onopenCallback function Once connected, call onopenCallback().
onclosedCallback type If the connection is closed by the remote host, call onclosedCallback().
Source:
Returns:
Type
undefined

connectByFace()

Deprecated:
  • This is deprecated. You should not call Transport.connect directly, since it is called by Face methods.
Source:

connectHelper(connectionInfoOrSocketTransport, elementListener)

Do the work to connect to the socket. This replaces a previous connection and sets connectionInfo.
Parameters:
Name Type Description
connectionInfoOrSocketTransport XpcomTransport.ConnectionInfo | object The connectionInfo with the host and port to connect to. However, if this is not a Transport.ConnectionInfo, assume it is an nsISocketTransport which is already configured for a host and port, in which case set connectionInfo to new XpcomTransport.ConnectionInfo(connectionInfoOrSocketTransport.host, connectionInfoOrSocketTransport.port).
elementListener object The elementListener with function onReceivedElement which must remain valid during the life of this object. Listen on the port to read an entire element and call elementListener.onReceivedElement(element).
Source:

isLocal(onResult, onError)

Determine whether this transport connecting according to connectionInfo is to a node on the current machine; results are cached. According to http://redmine.named-data.net/projects/nfd/wiki/ScopeControl#local-face, TCP transports with a loopback address are local. If connectionInfo contains a host name, this will do a DNS lookup; otherwise this will parse the IP address and examine the first octet to determine if it is a loopback address (e.g. the first IPv4 octet is 127 or IPv6 is "::1").
Parameters:
Name Type Description
onResult function On success, this calls onResult(isLocal) where isLocal is true if the host is local, false if not. We use callbacks because this may need to do an asynchronous DNS lookup.
onError function On failure for DNS lookup or other error, this calls onError(message) where message is an error string.
Source:

send()

Send the data over the connection created by connect.
Source:

setHttpListener(listener)

If the first data received on the connection is an HTTP request, call listener.onHttpRequest(transport, request) where transport is this transport object and request is a string with the request.
Parameters:
Name Type Description
listener object An object with onHttpRequest, or null to not respond to HTTP messages.
Source: