Node Monitor v0.6.5

Show:

Server Class

Extends Backbone.Model
Defined in: lib/Server.js:16
Module: Monitor

A server for accepting inbound connections from remote monitors

Servers are created when a process wants to expose probe data to remote monitors. Example:

// Accept remote monitors
var server = new Monitor.Server();
server.start();

An instance of this class represents a listening server accepting inbound connections. As inbound connections are detected, a new Connection object is created to manage traffic on that connection.

Security: Make sure the port range specified in Monitor.Config (starting at 42000) is not exposed outside your internal network. If you desire a different security model, create your secure server and pass it to the constructor.

Constructor

Server

(
  • model
)

Parameters:

  • model Object
    • Initial data model. Can be a JS object or another Model.
    • gateway Boolean
      • Allow incoming monitors to use me as a gateway (default false)
    • server HttpServer
      • The listening node.js server. Constructed by this class, or specified if a custom server is desired.
    • port Integer
      • The connected port. This is set upon start() if the server isn't specified on construction.

Item Index

Methods

Events

Methods

bindEvents

(
  • callback
)
protected

Bind incoming socket events to the server

This method binds to the socket events and attaches the socket.io server. It is called when the connection starts listening.

Parameters:

  • callback Function(error)
    • Called when all events are bound

List

(
  • [items]
)
Backbone.Collection static

Constructor for a list of Server objects

var myList = new Server.List(initialElements);

Parameters:

  • [items] Array optional

    Initial list items. These can be raw JS objects or Server data model objects.

Returns:

Backbone.Collection: Collection of Server data model objects

start

(
  • options
  • callback
)

Start accepting monitor connections

This method starts listening for incoming monitor connections on the server.

If the server was specified during object creation, this binds the socket.io service to the server.

If the server was not specified during object creation, this will create a server on the first available monitor port.

Parameters:

  • options Object
    • Start options. OPTIONAL
    • port Integer
      • Port to attempt listening on if server isn't specified. Default: 42000
    • attempt Integer
      • Attempt number for internal recursion detection. Default: 1
  • callback Function(error)
    • Called when the server is accepting connections.

stop

(
  • callback
)

Stop processing inbound monitor traffic

This method stops accepting new inbound monitor connections, and closes all existing monitor connections associated with the server.

Parameters:

  • callback Function(error)
    • Called when the server has stopped

Events

error

A client error has been detected

This event is fired if an error has been detected in the underlying transport. It may indicate message loss, and may result in a subsequent stop event if the connection cannot be restored.

start

The server has started

This event is fired when the server has determined the port to accept connections on, and has successfully configured the server to start accepting new monitor connections.

stop

The server has stopped

This event is fired after the server has stopped accepting inbound connections, and has closed all existing connections and released associated resources.