net¶
Object: jstp.net¶
jstp.net.connect(app, client, ...args, callback)¶
app
<string>
|<Object>
Application to connect to as'name'
or'name@version'
or{ name, version }
, where version must be a valid semver range.client
<Client>
|<null>
Optional, when omitted, an object with the default values forapplication
,connectPolicy
andreconnector
is used....args
<any>
Arguments passed directly tonet.connect()
(except forconnectListener
)callback
<Function>
error
:<Error>
connection
:<Connection>
jstp.net.connectAndInspect(app, client, interfaces, ...args, callback)¶
app
<string>
|<Object>
Application to connect to as'name'
or'name@version'
or{ name, version }
, where version must be a valid semver range.client
<Client>
|<null>
Optional, when omitted, an object with the default values forapplication
,connectPolicy
andreconnector
is used.interfaces
<string[]>
Interface names to perform inspect on....args
<any>
Arguments passed directly tonet.connect()
(except forconnectListener
).callback
<Function>
error
:<Error>
connection
:<Connection>
proxies
<Object>
[interfaceName]
<RemoteProxy>
Connects to the server and sends 'inspect'
messages for the requested
interfaces.
In case all of the inspect calls were successful, an object containing remote
proxies is returned.
It is possible, when using this method, to get an error
jstp.ERR_INTERFACE_NOT_FOUND
passed to the callback
due to
some of the 'inspect'
calls failing, and still receive a usable connection
object.
jstp.net.reconnect(connection, ...args, callback)¶
connection
:<Connection>
...args
<any>
Arguments passed directly tonet.connect()
(except forconnectListener
)callback
<Function>
error
:<Error>
connection
:<Connection>
This method can be used to reconnect to the same session without switching to
the new Connection
instance.
At the moment, when using this on a still alive connection, server implementation provided by this package closes the previous network connection on its side, but in general, it is not recommended to use this method on such connections, since there is no guarantee that the server will close the already existing network connection during reconnection and thus it may result in a dangling network connection.
jstp.net.createServer(options[, listener])¶
options
<Object>
|<Application[]>
applications
<Application[]>
|Map
Applications array or index obtained fromjstp.createAppsIndex()
.authPolicy
<AuthPolicy>
|<Function>
If the function is provided, it is expected to have the same signature asAuthPolicy.authenticate()
.sessionStorageProvider
<SessionStorageProvider>
If provided, this is used to store sessions for applications that do not have its own storage provider. Defaults to usingSimpleSessionStorageProvider
with its default settings.heartbeatInterval
<number>
Omitting this option disables heartbeat.clientExpirationTime
<number>
Time it takes for client's connection and corresponding session cache, stored in memory after the connection is closed, to expire. Defaults to3600000
(1 hour).
listener
<Function>
Automatically set as a listener for the'connect'
event.
For additional options see documentation for
net.createServer()
. However, beware, some of the options
may interfere with the correct functioning of the JSTP protocol.
authPolicy
is used whenever the handshake with authentication strategy other
than 'anonymous'
or 'session'
is received. In case it is omitted from the
options, using any other strategy will result in
jstp.ERR_AUTH_FAILED
error.