Connection Class
Connection with a remote process
Instances of this class represent a connection with a remote monitor process. The remote process is a peer of this process - it may produce and/or consume probe information.
This is an internal class created when a connection to a server is requested from a monitor, or when an external connection is made from a Server instance.
Constructor
Connection
-
model
Parameters:
-
model
Object- Initial data model. Can be a JS object or another Model.
-
[hostName]
String optionalThe host name to connect with. Used if url isn't present.
-
[hostPort]
Number optionalThe host port to connect using. Used if url isn't present.
-
[url]
String optionalThe URL used to connect. Built if hostName is supplied.
-
[socket]
Io.socket optionalUse this pre-connected socket instead of creating a new one.
-
[gateway=false]
Boolean optionalAllow this connection to use me as a gateway? See
Router.setGateway()
-
[firewall=false]
Boolean optionalFirewall inbound probe requests on this connection?
-
[remoteHostName]
String READONLY optionalHost name given by the remote server.
-
[remoteAppName]
String READONLY optionalApp name given by the remote server.
-
[remoteAppInstance]
Integer READONLY optionalThe remote application instance ID running on the host.
-
[remotePID]
String READONLY optionalRemote process ID.
-
[remoteProbeClasses]
Array of String READONLY optionalArray of probe classes available to the remote server.
-
[remoteGateway]
Boolean READONLY optionalCan the remote process act as a gateway?
-
[remoteFirewall]
Boolean READONLY optionalIs the remote side firewalled from inbound probe requests?
Item Index
Methods
Events
Methods
addEvent
-
eventName
-
handler
Bind the specified handler to the remote socket message.
Only a single handler (per message name) can be bound using this method.
Parameters:
-
eventName
StringThe event name to handle
-
handler
Function (args..., callback)Called when the message is received.
- args... {Mixed} Arguments sent in by the remote client
- callback {Function} Final arg if the client specified a callback
disconnect
-
reason
Disconnect from the remote process
This can be called from the underlying transport if it detects a disconnect, or it can be manually called to force a disconnect.
Parameters:
-
reason
StringReason for the disconnect
emit
-
name
-
args...
-
callback
Emit the specified message to the socket.
The other side of the connection can handle and respond to the message using the 'on' method.
isThisHost
-
hostName
Is this connection with the specified host?
Parameters:
-
hostName
StringThe host name to check
Returns:
List
-
[items]
Constructor for a list of Connection objects
var myList = new Connection.List(initialElements);
Parameters:
-
[items]
Array optionalInitial list items. These can be raw JS objects or Connection data model objects.
Returns:
ping
-
callback
Ping a remote connection
Parameters:
-
callback
Function(error)Callback when response is returned
probeConnect
-
monitorJSON
-
callback
Process an inbound request to connect with a probe
This will fail if this connection was created as a firewall.
Parameters:
-
monitorJSON
ObjectProbe connection parameters, including:
-
callback
Function(error, probeJSON)Callback function
probeControl
-
params
-
callback
Process an inbound control request to a probe
Parameters:
-
params
ObjectControl parameters, including: probeId {String} The unique probe id name {String} The control message name params {Object} Any control message parameters
-
callback
Function(error, returnParams)Callback function
probeDisconnect
-
params
-
callback
Process an inbound request to disconnect with a probe
Parameters:
-
params
ObjectDisconnect parameters, including: probeId {String} The unique probe id
-
callback
Function(error)Callback function
Events
connect
Connected to remote monitor process
This event is emitted after the two sides of the connection have exchanged information about themselves.
disconnect
Disconnected from a remote monitor process
This event is emitted after the remote connection is disconnected and resources released.
Event Payload:
-
reason
StringReason for the disconnect