Class: Interface

Interface

new Interface(server, options)

Parameters:
Name Type Description
server Server the server utilizing the interface
options Object the interface options
Since:
  • 0.6.0
Source:

Methods

close(done)

This function is used to close the interface and disconnect all active connections
Parameters:
Name Type Description
done Interface~finishedClose the callback to invoke when finished closing
Since:
  • 0.6.0
Source:

getBaseMessage() → {string}

This function is used to get the base message for interface logging
Since:
  • 0.6.o
Source:
Returns:
the base logging message
Type
string

getConnections() → {Array}

This function is used to get all of the connections connected to the interface
Since:
  • 0.6.0
Source:
Returns:
the connected connections
Type
Array

getFormattedListen() → {string}

This function is used to get the formatted interface address
Since:
  • 0.6.0
Source:
Returns:
the formatted address the interface *should* be listening on
Type
string

getID() → {int}

This function is used to get the interface's ID
Since:
  • 0.6.0
Source:
Returns:
the interface's id
Type
int

getOptions() → {Object}

This function is used to get the interface's options
Since:
  • 0.6.0
Source:
Returns:
the interface's options
Type
Object

getServer() → {Server}

This function is used to get the server utilizing the interface
Since:
  • 0.6.0
Source:
Returns:
the server utilizing the interface
Type
Server

getSocket() → {net.Server}

This function is used to get the socket the interface is listening for connections on
Since:
  • 0.6.0
Source:
Returns:
the socket the server is listening on
Type
net.Server

isSetup() → {boolean}

This function is used to tell wether or not the interface have been setup
Since:
  • 0.6.0
Source:
Returns:
true if the server have been setup, false if not
Type
boolean

listen(callback)

This function is used to tell the interface to bind to the address it's been provided and start to liten for connections The function will setup the interface if it haven't been done at the time of execution
Parameters:
Name Type Description
callback Interface~didListen the callback to invoke when bound and accepting clients
Since:
  • 0.6.0
Source:

onConnection(connection)

This function gets invoked when a new connection have been made to the interface
Parameters:
Name Type Description
connection net.Socket the connection object
Since:
  • 0.6.0
Source:

onError(error)

This function gets invoked when an error occurs with the interface. Usually this is FATAL
Parameters:
Name Type Description
error Error the error
Since:
  • 0.6.0
Source:

setup(callback)

This function is used to setup the interface in this order: - Check for tls certificate - Read certificate into memory - Create socket - Setup listeners
Parameters:
Name Type Description
callback Interface~didSetup the callback to invoke when finished
Since:
  • 0.6.0
Source:

Type Definitions

didListen()

This callback is used to when the interface have successfully bound to the provided address and is now accepting connections
Since:
  • 0.6.0
Source:

didSetup(the)

This callback is used when the interface have finished setting up
Parameters:
Name Type Description
the Interface interface that finished setting up
Since:
  • 0.6.0
Source:

finishedClose()

This callback is used when the interface have closed and finished disconnecting all connections
Since:
  • 0.6.0
Source: