API Version: Development

IPCortex.PBX Object

Kind: static object IPCortex.PBX
This is the top level container for PBX API methods.

Live data functions

IPCortex.PBX.startFeed([options]) ⇒ Promise

IPCortex.PBX.startFeed([callback], [error], [options]) ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves with no data.
May be called using optional callbacks:
Parameter Type Description
[callback] Function Success callback, passed no parameters.
[error] Function Failure callback, called as Function(Number errno, String description)
[options] Object If null or empty, enable all available datasets, otherwise, only enable specified eg: {device: true, queue: true}
  • device - (Bool) Include device states and their calls.
  • deviceMin - (Bool) Reduce output of device option to user's own devices.
  • mailbox - (Bool) Include mailbox information.
  • queue - (Bool) Add additional queue member feed.
  • presence - (Bool) Add presence data (used by chat.)
  • pingtime - (Number) Websocket keepalive ping time (10 to 999 seconds, 9 minute default)
  • errorCB - (Function) Pass error callback as an option if using short-form of startFeed()
  • maxWSRetryTime - (Number) Number of seconds to retry after WS error, 0 for no retry, null for indefinite.
  • Setting pingtime or errorCB only will still enable all datasets.
A Promise is returned which may optionally be used in place of the callbacks, though the promise will reject only once the errorCB is useful for trapping errors occuring after a successful start.
If maxWSRetryTime is triggered, then stopFeed() is called automatically, and will clean up all internal data structures.
IMPORTANT The error callback can be used to detect unecpected or externally caused logout events. It is called with errno and errString parameters.
errno Meaning
1 Internal error, recovery will be attempted but is not assured
2 The user has been logged-out
3 Not ready yet, keep trying.
90 Error from backend with no number provided
91 WS Open failure
92 WS Error during operation
100 The PABX version does not match the originally loaded version (eg. after an upgrade)

IPCortex.PBX.pauseFeed() ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves with no data.
Pause the live data feed. IPCortex.PBX.startFeed() is used to reconnect and resume live data with all previous settings.

IPCortex.PBX.stopPoll() ⇒ Promise

IPCortex.PBX.stopFeed() ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves with no data.
Stop the live data feed. stopPoll() is a legacy name for this call.

IPCortex.PBX.setIdle(enable) ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves with no data.
Puts the live feed into or out of 'IDLE' mode, which causes only data directly related to the logged-in user to be sent through the live data feed. If using the 'Lite' API, this mode is enabled and cannot be disabled.
Parameter Type Description
enable Bool true: enable, false: disable

IPCortex.PBX.fetchData([callback], [error]) ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves with no data.
Request to fetch the same base data set that startFeed() enabled, but does NOT enable the live feed or any of the related updates.
May be called using optional callbacks:
Parameter Type Description
[callback] Function Success callback, passed no parameters.
[error] Function Failure callback, called as Function(Number errno, String description)
A Promise is returned which may optionally be used in place of the callbacks.

IPCortex.PBX.enableTags() ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves with no data.
Fetch any #tags saved against contacts, and automatically keep them up-to-date with changes. This method should be called (and resolved) before getAddressbook() is used otherwise tags may not be correctly populated.
Tags can be read from Address or Contact classes, and where permission is available, writing an Array back to a Contact or Address entry will update the tags list. Permission is available to set tags if the 'Receptionist' role has been set, for company and system administrators, and each individual can change their own tags.

IPCortex.PBX.disableTags() ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves with no data.
Discard and contact tags and stop automatic updates. This cancels the actions of IPCortex.PBX.enableTags()

IPCortex.PBX.restRequest(path, data, [callback]) ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves with response data as a JS Object.
Parameter Type Description
path String REST path
data Object REST data - This call will JSON.stringify() the data before sending
[callback] Function Success callback, passed no parameters.
A Promise is returned which may optionally be used in place of the callback.

General purpose functions

IPCortex.PBX.getLines([callback], [owned]) ⇒ Promise

IPCortex.PBX.getLines([callback], [owned, immediate = true]) ⇒ Array

Kind: static method of IPCortex.PBX Returns: (If immediate is false/null) Promise - Resolves to an ordered list of lines Returns: (If immediate is true) Array - An ordered list of lines
Register a callback to be fed a list of Device objects that are used by the logged-in user. Events such as hotdesking may result in this callback being called repeatedly to provide updates.
In the form where no callback is provided, the call returns a single (non-updating) result as a Promise.
Parameter Type Description
callback Function Callback with a list of Device objects whenever the list of Devices changes.
owned Bool (Optional) Only return 'owned' devices
immediate Bool (Optional) Do not callback, return the list directly

IPCortex.PBX.getAddressbook([callback]) ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves to a list of all addresses
Causes the fetching of the addressbook from the PBX, and the subsequent updating of the addressbook if changes are detected. There are many cases which will not be detected as realtime addressbook updates would cause too great a load on the system.
Parameter Type Description
[callback] Function Callback with Function(Array added, Array removed) added is a list of Address objects discovered since the last callback. removed is a list of Address objects removed since the last callback.
When initially called, Array added will contain a list of all addressbook entries. This is the same result as returned to the Promise when it resolves. The Array removed will initially be empty. Should a change subsequently happen to the addressbook, the callback will provide a list of new entries in 'added'. Each addressbook entry has an address.key property; This key is used for the 'removed' list, which lists the keys of addressbook entries that are deleted. The client application is expected to clean up all references to addressbook entries that have been removed.
NOTE: It is possible if preferred to ignore one or both of the 'added' and 'removed' values, and instead use 'new' or 'deleted' event handlers on the address objects.

IPCortex.PBX.getTimeDelta

Kind: static method of IPCortex.PBX Returns: Promise - Resolves to the same object as used in the callback.
This utility allows the application to detect a time difference between the client an server clocks in case this affects the API or client application.
Parameter Type Description
callback Function (Optional) Callback with {clientTime: seconds, serverTime: seconds, driftTime: drift} drift is calculated as clientTime - serverTime, so will be positive if the client clock is fast.

IPCortex.PBX.restRequest(path, [data], [callback]) ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves to the result object.
Parameter Type Description
path String REST call path including the leading '/'
[data] Object REST call data, defaults to {}
[callback] Function (Optional) Callback with the result object.

IPCortex.PBX.setIce(stun, turn) ⇒ Promise

Kind: static method of IPCortex.PBX Returns: Promise - Resolves with no data.
Option to override STUN and TURN servers to be used by WebRTC based components. The default is set from the PABX.
Parameter Type Description
stun String FQHN or FQHN:port for the stun server.
turn Array List of Objects containing: {urls:, username:, credential:}