kandy

4.8.0

create

The SDK creation factory. Create an instance of the SDK by calling this factory with the desired configurations.

create(config: config)
Parameters
config (config) The configuration object.
Example
// Instantiate the SDK.
import { create } from 'kandy'
const client = create({
    authentication: { ... },
    logs: { ... },
    ...
});
// Use the SDK's API.
client.on( ... );

config

The configuration object. This object defines what different configuration values you can use when instantiating the SDK using the create function.

config
Configurations By Feature
config.logs
config.authentication
config.call
config.connectivity
config.notifications

Configuration

An interface for getting and updating the configuration Object.

Configuration functions are available directly on the SDK Object

Configuration
Functions
getConfig()
updateConfig(newConfigValues)

getBrowserDetails

Retrieve information about the browser being used.

Browser information being defined indicates that the browser supports basic webRTC scenarios.

getBrowserDetails(): Object
Returns
Object: Object containing browser and version information.
Example
const details = client.getBrowserDetails()

log(`Browser in use: ${details.browser}, version ${details.version}.`)

Authentication

The authentication feature handles connecting and disconnecting from any backend services that the SDK deals with. As well, it handles and stores authentication information on the behalf of the user. This allows the user to interact with the server without worrying about authenticating.

Authentication
Functions
connect(credentials)
connect(credentials)
connect(credentials)
connect(credentials)
disconnect()
updateToken(credentials)
updateToken(credentials, credentials)
getUserInfo()
getConnection()
getServices()
subscriptionStates
disconnectReasons
Events
auth:change
auth:error
auth:resub

BasicError

The Basic Error object. Provides information about an error that occurred in the SDK.

BasicError
Properties
code (string) : The code of the error. If no code is known, this will be 'NO_CODE'.
message (string) : A human-readable message to describe the error. If no message is known, this will be 'An error occured'.

CallHistory

The call history feature is used to retrieve and inspect the authenticated users call logs.

CallHistory functions are all part of the 'call.history' namespace.

CallHistory
Functions
fetch(amount, offset)
remove(recordId)
clear()
get()
getCache()
setCache(data)
Events
callHistory:change
callHistory:error
callHistoryCache:change

Calls

The Calls feature is used to make audio and video calls to and from SIP users and PSTN phones.

Call functions are all part of the 'call' namespace.

Calls
Types
MediaObject
CallObject
MediaConstraint
BandwidthControls
IceServer
SdpHandlerInfo
SdpHandlerFunction(newSdp, info, originalSdp)
TrackObject
DeviceInfo
DevicesObject
Functions
make(destination, media, options?)
reject(callId)
answer(callId, media, options?)
ignore(callId)
hold(callId)
unhold(callId)
getAll()
getById(callId)
end(callId)
addMedia(callId, media, options = {})
removeMedia(callId, tracks, options = {})
sendDTMF(callId, tone, duration, intertoneGap)
getStats(callId, trackId?)
consultativeTransfer(callId, otherCallId)
join(callId, otherCallId)
replaceTrack(callId, trackId, media)
states
Events
call:start
call:join
call:receive
call:stateChange
call:newMedia
call:removedMedia
call:newTrack
call:trackEnded
call:statsReceived
call:trackReplaced

ClickToCall

The clickToCall feature is used to bridge a call between two specified devices

ClickToCall
Functions
clickToCall(caller, callee)
get()
Events
clickToCall:start
clickToCall:error

Connectivity

The connection feature is used to connect and maintain connections between the SDK and one or more backend servers.

Connectivity functions are all part of the 'connection' namespace.

Connectivity
Functions
getSocketState(platform)
enableConnectivityChecking(enable)
Events
ws:change

Contacts

The Contacts feature allows users to store personal contacts to their account.

These functions are namespaced beneath 'contacts' on the API.

Contacts
Functions
add(contact)
get(contactId)
getAll()
refresh()
remove(id)
update(contact)
fetch(contactId)
Events
contacts:new
contacts:error
contacts:change

Events

The Events feature allows an application to listen for events that the SDK emits. Each other feature has a set of event types that can be subscribed to using the Event APIs.

Events
Functions
on(type, listener)
off(type, listener)
subscribe(listener)
unsubscribe(listener)

Logger

The internal logger is used to provide information about the SDK's behaviour. The logger can provide two types of logs: basic logs and action logs. Basic logs are simple lines of information about what the SDK is doing during operations. Action logs are complete information about a specific action that occurred within the SDK, providing debug information describing it. The amount of information logged can be configured as part of the SDK configuration. See config.logs .

Logger
Functions
levels

Media

The Media feature provides an interface for interacting with Media that the SDK has access to. Media is used conjunction with the Calls feature to manipulate and render the Tracks sent and received from a Call.

Media and Track objects are not created directly, but are created as part of Call operations. Media and Tracks will either be marked as "local" or "remote" depending on whether their source is the local user's machine or a remote user's machine.

The Media feature also keeps track of media devices that the user's machine can access. Any media device (eg. USB headset) connected to the machine can be used as a source for media. Available devices can be found using the media.getDevices API.

Media functions are all part of the 'media' namespace.

Media
Functions
getDevices()
getById(mediaId)
getTrackById(trackId)
renderTracks(trackIds, cssSelector, options?)
removeTracks(trackIds, cssSelector)
muteTracks(trackIds)
unmuteTracks(trackIds)
Events
devices:change
media:muted
media:unmuted

Messaging

The messaging feature revolves around a "conversation" structure. It is responsible to store the conversations and its messages, and return conversation objects when requested.

See the "Conversation" and "Message" sections of the documentation for more details.

Messaging functions are all part of the 'conversation' namespace. Ex: client.conversation.get('id').

Messaging
Types
Conversation
Message
Functions
fetch(options?)
get(destination, options?)
create(recipient, type, options)
Events
conversations:new
conversations:change
messages:change
messages:error

Notification

Notification
Functions
process(notification, channel?)
registerPush(params)
deregisterPush()
enableWebsocket(enable)
Events
notifications:change
notifications:error

Presence

The Presence feature provides an interface for an application to set the User's presence information and to track other Users' presence information.

Presence information is persisted by the server. When the SDK is initialized, there will be no information available. Presence information will become available either by using presence.fetch or by subscribing for updates about other Users, using presence.subscribe.

Available presence information can be retrieved using presence.get or presence.getAll.

Presence APIs are part of the 'presence' namespace.

Presence
Functions
statuses
activities
update(status, activity, note?)
get(user)
getAll()
getSelf()
fetch(user)
subscribe(users)
unsubscribe(users)
Events
presence:change
presence:selfChange
presence:error

sdpHandlers

A set of SdpHandlerFunctions for manipulating SDP information. These handlers are used to customize low-level call behaviour for very specific environments and/or scenarios. They can be provided during SDK instantiation to be used for all calls.

sdpHandlers
Example
import { create, sdpHandlers } from 'kandy';
const codecRemover = sdpHandlers.createCodecRemover(['VP8', 'VP9'])
const client = create({
  call: {
    sdpHandlers: [ <Your-SDP-Handler-Function>, ...]
  }
})
Functions
createCodecRemover(codecs)

SipEvents

Allows a user to subscribe to, and receive notifications for, sip events.

SipEvents functions are all part of the 'sip' namespace.

SipEvents
Functions
subscribe(eventType, subscribeUserList, clientCorrelator, customParameters?)
update(eventType, userLists, customParameters?)
unsubscribe(eventType)
getDetails(eventType?)
Events
sip:subscriptionChange
sip:error
sip:eventsChange

Users

The Users feature allows access to user information for users within the same domain.

The functions in this module are namespaced under 'user'.

Users
Types
User
Functions
fetch(userId)
fetchSelfInfo()
get(userId)
getAll()
search(filters, options?)
Events
directory:change
directory:error

Voicemail

The voicemail features are used to retrieve and view voicemail indicators.

Voicemail functions are all part of the 'voicemail' namespace.

Voicemail
Functions
fetch()
get()
Events
voicemail:change
voicemail:error