API Docs for: 2.6
Show:

com_nethcti_tcp Class

Module: com_nethcti_tcp

Core module that communicates with clients using a TCP connection.

Methods

addSocket

(
  • socket
)

Adds the client socket into the private object sockets. If it already exists it will be overwritten.

Parameters:

  • socket String

    The client socket private

config

(
  • path
)

Configurates the TCP server properties by a configuration file. The file must use the JSON syntax.

Parameters:

  • path String

    The path of the configuration file

configWinPopup

(
  • path
)

Configurates the settings to be used for Windows popup notifications of incoming calls by a configuration file. The file must use the JSON syntax.

Parameters:

  • path String

    The path of the configuration file

connHdlr

(
  • socket
)
private

TCP server connection handler. A new client connection has been made.

Parameters:

  • socket Object

    The client socket

disconnHdlr

(
  • socket
)
private

Client socket disconnection handler.

Parameters:

  • socket Object

    The client socket

extenDialing

(
  • data
)
private

Handler for the extenDialing event emitted by ast_proxy component. The extension ringing, so notify all users associated with it, with the identity data of the caller.

Parameters:

  • data Object
    • dialingExten String

      The identifier of the ringing extension

    • callerIdentity Object

      The identity data of the caller

getFilteredCallerData

(
  • username
  • callerIdentity
)
Object private

Returns identity data of the caller filtered by user authorizations. Returned caller notes are those all of the user and the publics of the others if he has only the "postit" authorization and all the caller notes if he has the "admin postit" authorization. Phonebook contacts returned is the one created by the user in the cti phonebook, or one from the centralized phonebook or a public contact created by other users in the cti address book.

Parameters:

  • username String

    The username

  • callerIdentity Object

    The identity of the caller to be filtered

Returns:

Object:

The filtered caller identity data

getFilteredStreamData

(
  • username
  • callerNum
)
Object private

Returns data about the streaming source filtered by user authorizations. If the user doesn't have the authorization, an empty object is returned.

Parameters:

  • username String

    The username

  • callerNum String

    The number of the caller

Returns:

Object:

The filtered streaming data

getNumConnectedClients

(
  • The
)
private

Returns the number of connected clients.

Parameters:

  • The Number

    number of connected clients.

getSocketEndpoint

(
  • socket
)
String private

Returns the endpoint of the client socket. The endpoint is constructed by ip_address:port.

Parameters:

  • socket Object

    The TCP client socket

Returns:

String:

The socket endpoint as ip_address:port.

loginHdlr

(
  • socket
  • obj
)
private

TCP socket login handler.

Parameters:

  • socket Object

    The client socket

  • obj Object
    • username String

      The username of the account

    • token String

      The token constructed with the authentication REST request

pingHdlr

(
  • socket
)
private

TCP socket ping handler. It responds with an "active" message.

Parameters:

  • socket Object

    The client socket

removeClientSocket

(
  • socketId
)

Removes the client socket from the private object sockets.

Parameters:

  • socketId String

    The client socket identifier private

resetCommandsHdlr

(
  • socket
  • obj
)
private

The handler to reset the commands of a nethifier client.

Parameters:

  • socket Object

    The client socket

  • obj Object
    • username String

      The username of the account

    • token String

      The token constructed with the authentication REST request

send401

(
  • socket
)
private

Send 401 unauthorization response through the client socket.

Parameters:

  • socket Object

    The client socket

sendAutheSuccess

(
  • socket
)
private

Send authorized successfully response to the client by socket.

Parameters:

  • socket Object

    The client socket

sendCallNotificationEvent

(
  • username
  • data
  • socket
)
private

Sends the event to open a desktop notification popup about an incoming call.

Parameters:

  • username String

    The username of the client

  • data Object

    The data about the caller

  • socket Object

    The TCP socket client

sendNotificationSupportedCommands

(
  • socket
)
private

Send supported commands by the windows notifications of incoming calls.

Parameters:

  • socket Object

    The client socket

sendResetNotificationSupportedCommands

(
  • socket
)
private

Sends the message to reset the supported commands by the windows notifications client.

Parameters:

  • socket Object

    The client socket

sendStreamingNotificationEvent

(
  • username
  • data
  • socket
)
private

Sends the event to open a desktop notification popup about a streaming source.

Parameters:

  • username String

    The username of the client

  • data Object

    The data about the caller

  • socket Object

    The TCP socket client

setAstProxy

(
  • ap
)

Set the asterisk proxy to be used by the module.

Parameters:

  • ap Object

setAstProxyListeners

() private

Sets the event listeners for the asterisk proxy component.

setCompAuthe

(
  • autheMod
)

Set the authentication module to be used.

Parameters:

  • autheMod Object

    The authentication module.

setCompAuthorization

(
  • comp
)

Sets the authorization module to be used.

Parameters:

  • comp Object

    The authorization module.

setCompConfigManager

(
  • comp
)

Sets the config manager module to be used.

Parameters:

  • comp Object

    The config manager module.

setCompStreaming

(
  • comp
)

Set the streaming module to be used.

Parameters:

  • comp Object

    The streaming module.

setCompUser

(
  • comp
)

Sets the user module to be used.

Parameters:

  • comp Object

    The user module.

setLogger

(
  • log
)
static

Set 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

()

Creates the TCP server and adds the listeners for other components.

unauthorized

(
  • socket
)
private

Manage unauthorized access. It send 401 unauthorized response to the client and disconnect the socket.

Parameters:

  • socket Object

    The client socket

updateTokenExpirationOfAllTcpUsers

() private

Update the token expiration of all users that are connected by TCP.

Properties

CALL_NOTIF_TEMPLATE_NAME

String private final

The name of the template file for a call notification popup.

Default: "call.html"

callNotifSize

Object private

The size of the call notification popup. It is customized by the configWinPopup method.

Default: { width: 400, heigth: 96 }

callNotifTemplatePath

String private

The path of the template file for a call notification popup. It is constructed by the config method.

compAstProxy

Object private

The asterisk proxy component.

compAuthe

Object private

The authentication module.

compAuthorization

Object private

The authorization module.

compConfigManager

Object private

The config manager module.

compStreaming

Object private

The streaming component.

compUser

Object private

The user component.

ctiProto

String private

The protocol used by the cti server. It is used by the windows popup notification to open the NethCTI application using the configured protocol. It is customized by the configuration file.

Default: "https"

ENCODING

String private final

The enconding used to write the TCP client sockets.

Default: "utf8"

IDLOG

String private final

The module identifier used by the logger.

Default: [com_nethcti_tcp]

logger

Object private

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

Default: console

notifCloseTimeout

String private

The timeout to automatic close notification popup.

Default: 10

notifSupportedCommands

Object private

The supported commands for windows popup notifications. It is initialized by the configWinPopup method.

Default: {}

port

String private

The TCP server port. It is customized by the configuration file.

server

Object private

The TCP server.

sockets

Object private

Contains all client socket of authenticated clients. The key is the client socket identifier and the value is an object containing the socket object and the token of the user.

STREAMING_NOTIF_TEMPLATE_NAME

String private final

The name of the template file for a streaming notification popup.

Default: "streaming.html"

streamingNotifTemplatePath

String private

The path of the template file for a streaming notification popup. It is constructed by the config method.

streamNotifSize

Object private

The size of the streaming notification popup. It is customized by the configWinPopup method.

Default: { width: 400, heigth: 400 }

updateTokenExpirationInterval

Number private

Interval time to automatic update token expiration of all users that are connected by socket.