API Docs for: 2.6
Show:

ast_proxy Class

Module: ast_proxy

Asterisk proxy with standard interface to use.

Methods

accept

() private

Sets the component's visitors.

amiSocketClose

(
  • had_error
)
private

Handler for the ami_socket_close event emitted once the socket is fully closed. The argument had_error is a boolean which says if the socket was closed due to a transmission error

Parameters:

  • had_error Boolean

    It says if the socket was closed due to a transmission error

amiSocketEnd

() private

Handler for the ami_socket_end event emitted when the other end of the socket sends a FIN packet.

amiSocketError

(
  • err
)
private

Handler for the ami_socket_error event emitted when an error occurs, e.g. when lost the connection. The 'close' event will be calledd directly following this event.

Parameters:

  • err Object

    The error object

amiSocketTimeout

() private

Handler for the ami_socket_timeout event emitted when the socket times out from inactivity. This is only to notify that the socket has been idle. The user must manually close the connection.

amiSocketUnwritable

() private

Handler for the ami_socket_unwritable event emitted when the socket isn't writable.

config

(
  • path
)

Sets the configuration to be use to establish the telnet asterisk connection.

Parameters:

  • path String

    The file path of the JSON configuration file that contains the host, port, user and password of the asterisk server

configAstCodes

(
  • path
)

Sets the asterisk codes to be used for some functions.

Parameters:

  • path String

    The file path of the JSON configuration file that contains the asterisk codes

configRemoteSitePrefixes

(
  • path
)

Sets the remote sites to have remote sites prefixes.

Parameters:

  • path String

    The file path of the JSON configuration file that contains the remote sites

configSipWebrtc

(
  • path
)

Sets the configuration to be used by sip WebRTC.

Parameters:

  • path String

    The file path of the JSON configuration file

doCmd

(
  • obj
  • cb
)

Executes specified command and return result in the callback. It calls the execute method of the command plugin that has the same name of the specified command. The plugin is contained into the file that resides in the appropriate directory and must have a file name equal to specified command parameter.

e.g. If the command name is astVersion, the astVersion.js plugin must be present.

Parameters:

  • obj Object

    The object with the command name to execute and optional parameters

    • command String

      The command name to execute. A plugin command file with the same name must be present into the appropriate directory

    • [parameters] optional

      0..n The parameters that can be used into the command plugin

  • cb Function

    The callback

Example:

doCmd({ command: 'astVersion' }, function (res) {
    console.log(res);
});

doCmd({ command: 'dndGet', exten: '214' }, function (res) {
    console.log(res);
});

emit

(
  • ev
  • data
)

Emit an event. It's the same of nodejs events.EventEmitter.emit method.

Parameters:

  • ev String

    The name of the event

  • data Object

    The object to be emitted

getSipWebrtcConf

() Object

Returns the sip WebRTC configuration.

Returns:

Object:

The sip WebRTC configuration.

on

(
  • type
  • cb
)
Object

Subscribe a callback function to a custom event fired by this object. It's the same of nodejs events.EventEmitter.on method.

Parameters:

  • type String

    The name of the event

  • cb Function

    The callback to execute in response to the event

Returns:

Object:

A subscription handle capable of detaching that subscription.

onData

(
  • data
)
private

Handler for the received data from asterisk. It calls the execute method of the command plugin with the name that corresponds to the ActionID value contained in the data object. Plugins must reside in the appropriate directory.

e.g. If the data contains astVersion_12345 ActionID key, the astVersion.js plugin must be present.

Parameters:

  • data Object

    The data received from asterisk

setAllPluginsCmdLogger

(
  • log
)
private

Call setLogger function for all command plugins.

Parameters:

  • log Object

    The logger object.

setAllPluginsEventLogger

(
  • log
)
private

Call setLogger function for all event plugins.

Parameters:

  • log Object

    The logger object.

setLogger

(
  • log
)
static

Sets the logger to be used.

Parameters:

  • log Object

    The logger object. It must have at least three methods: info, warn and error as console object.

start

()

Start the telnet connection with the asterisk server and listen to any events.

Properties

am

Object private

The asterisk manager.

astConf

Object private

The asterisk connection parameters that are customized using the configuration file.

emitter

Object private

The event emitter.

IDLOG

String private final

The module identifier used by the logger.

Default: [ast_proxy]

INI_PATH_AST_STRUCT

String private final

It's the path of the ini file created by perl script. It contains the categorization of all peers: extensions, groups, trunks, parks and queues.

Default: "/etc/nethcti/structure.ini"

logger

Object private

The logger. It must have at least three methods: info, warn and error.

Default: console

self

Object private

It's this module.

sipWebrtcConf

Object private

The sip WebRCT configuration.