kandy
3.0.0-beta
- createKandy
- configs ▸
-
Events
▸
- Static members
- .on
- .off
- .subscribe
- .unsubscribe
-
Authentication
▸
- Static members
- .getUserInfo
- .getConnection
- .subscriptionStates
- Calls ▸
-
Media
▸
- Static members
- .setDefaultDevices
- .getDevices
-
Connectivity
▸
- Static members
- .getSocketState
- .enableConnectivityChecking
- Events
- ⓔ ws:change
-
Notification
▸
- Static members
- .registerPush
- .deregisterPush
- .enableWebsocket
-
sdpHandlers
▸
- Static members
- .createCodecRemover
-
Logger
▸
- Static members
- .levels
-
Config
▸
- Static members
- .getConfig
- .updateConfig
- KandyError
-
AudioBridge
▸
createKandy
The Kandy.js SDK Factory. Create an instance of the SDK by calling this factory with the the desired configurations.
(Object)
The configuration object.
// Instantiate the SDK.
let kandy = createKandy({
authentication: { ... },
logs: { ... },
...
});
// Use the Kandy API.
kandy.on( ... );
configs
The configuration object. This object defines what different configuration values you can use when instantiating the SDK.
Configuration options for the Logs feature.
(Object)
Logs configs.
Name | Description |
---|---|
logs.logLevel String
(default debug )
|
Log level to be set. See
kandy.logger.levels
.
|
logs.stackTraces Boolean
(default false )
|
Set whether the log manager should always provide a stack trace. |
logs.flatten Boolean
(default false )
|
Display the logged information as a string. |
logs.logActions Object?
|
Extra configs when logLevel is at DEBUG+ levels. Set this to false to not log actions. |
logs.logActions.actionLogger Boolean
(default false )
|
Override the logger provided to redux-logger. |
logs.logActions.actionOnly Boolean
(default true )
|
Only show the action payload. |
logs.logActions.collapsed Boolean
(default false )
|
Have logged objects be collapsed. |
logs.logActions.diff Boolean
(default false )
|
Display the diff for each action log. |
logs.logActions.colors Boolean
(default false )
|
Set whether colors are to be used in redux-logger |
logs.enableFcsLogs Boolean
(default true )
|
Enable the detailed call logger. |
Configuration options for the notification feature.
(Object)
The notifications configuration object.
Name | Description |
---|---|
notifications.idCacheLength number
(default 100 )
|
Default amount of event ids to remember for de-duplication purposes. |
notifications.pushRegistration Object?
|
Object describing the server to use for push services. |
notifications.pushRegistration.server string?
|
Hostname for the push registration server. |
notifications.pushRegistration.port string?
|
Port for the push registration server. |
notifications.pushRegistration.protocol string?
|
Protocol for the push registration server. |
notifications.pushRegistration.version string?
|
Version for the push registration server. |
notifications.realm string?
|
The realm used for push notifications |
notifications.bundleId string?
|
The bundle id used for push notifications |
Configuration options for the CallMe Authentication feature.
(Object)
Authentication configs.
Name | Description |
---|---|
authentication.subscription Object
|
|
authentication.subscription.protocol string
(default https )
|
Protocol to be used for subscription requests. |
authentication.subscription.server string
|
Server to be used for subscription requests. |
authentication.subscription.port Number
(default 443 )
|
Port to be used for subscription requests. |
authentication.subscription.version string
(default 1 )
|
Version of the REST API to be used. |
authentication.subscription.service Array?
|
Services to subscribe to for notifications. |
authentication.websocket Object
|
|
authentication.websocket.protocol string
(default wss )
|
Protocol to be used for websocket notifications. |
authentication.websocket.server string
|
Server to be used for websocket notifications. |
authentication.websocket.port Number
(default 443 )
|
Port to be used for websocket notifications. |
Configuration options for the call feature.
(Object)
The call configuration object.
Name | Description |
---|---|
call.callDefaults Object?
|
Default options to be used when making/answering a call. |
call.chromeExtensionId string?
|
ID of the Kandy Screenshare Extension being used for screenshare of Google Chrome. |
call.webrtcdtls boolean
(default true )
|
Whether to enable the webRTC DTLS setting for calls. |
Configuration options for the Connectivity feature.
(Object)
Connectivity configs.
Name | Description |
---|---|
connectivity.method String
(default 'keepAlive' )
|
The method of connectivity checking to use. Either 'keepAlive' or 'pingPong'. |
connectivity.pingInterval Number
(default 5000 )
|
Time in between websocket ping attempts (milliseconds). |
connectivity.reconnectLimit Number
(default 5 )
|
Number of failed reconnect attempts before reporting an error. |
connectivity.reconnectDelay Number
(default 5000 )
|
Base time between websocket reconnect attempts (milliseconds). |
connectivity.reconnectTimeMultiplier Number
(default 1 )
|
Reconnect delay multiplier for subsequent attempts. |
connectivity.reconnectTimeLimit Number
(default 640000 )
|
Maximum time delay between reconnect attempts (milliseconds). |
connectivity.reconnectCount Number
(default 0 )
|
Initial reconnect count. |
connectivity.autoReconnect Boolean
(default true )
|
Flag to determine whether Kandy will attempt to automatically reconnect after connectivity disruptions. |
connectivity.maxMissedPings Number
(default 3 )
|
Maximum pings sent (without receiving a response) before reporting an error. |
connectivity.checkConnectivity Boolean
(default false )
|
Flag to determine whether Kandy should check connectivity. |
Events
Authentication
Kandy's 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.
Get the connection state.
Object
:
connection The connection state.
boolean
:
connection.isConnected Whether the authenticated user is currently connected.
boolean
:
connection.isPending Whether the authenticated user's connection is currently pending.
Object
:
connection.error The error object if an error occured.
string
:
connection.error.message The error message.
string
:
connection.error.stack The stack trace of the error.
Calls
Kandy's call feature is used to make audio and video calls between Kandy users, or to PSTN phones and SIP endpoints. Kandy will store meta-information about each call made during the current session in internal state, which can be accessed via the call getter functions.
Call functions are namespaced beneath 'call' on the returned Kandy object.
Starts an outgoing call as an anonymous user.
(string)
Full user ID of the call recipient.
(object?)
Information needed to validate a token anonymous call.
Name | Description |
---|---|
credentials.accountToken object?
|
The encrypted account token of the account making the call. |
credentials.fromToken object?
|
The encrypted SIP address of the account/caller. |
credentials.toToken object?
|
The encrypted SIP address of the callee. |
credentials.realm object?
|
The realm used to encrypt the tokens. |
(Object?)
Call options.
Name | Description |
---|---|
callOptions.isVideoEnabled boolean
(default true )
|
Whether to enable video during the call. If false, you cannot start video mid-call. |
callOptions.sendInitialVideo boolean
(default false )
|
Whether to start the call sending the local video stream. |
callOptions.isAudioEnabled boolean
(default true )
|
Whether to enable audio during the call. Setting this to false will disable audio for the call. |
callOptions.webrtcdtls boolean
(default true )
|
Whether to enable DTLS for WebRTC calls. |
callOptions.videoResolution Object?
|
The object to configure the local video resolution. |
callOptions.videoResolution.height number?
|
The height in pixels of the local video. |
callOptions.videoResolution.width number?
|
The width in pixels of the local video. |
callOptions.remoteVideoContainer HTMLElement?
|
The HTML element to use as a container for the remote video. |
callOptions.localVideoContainer HTMLElement?
|
The HTML element to use as a container for the local video. |
string
:
Id of the outgoing call.
// Make a basic anonymous call.
let callee = 'user1@kandy.io';
let callOptions = { ... };
let callId = kandy.call.makeAnonymous(callee, {}, callOptions);
// Make a time-limited token anonymous call.
let callee = 'user1@kandy.io';
let account = 'user2@kandy.io';
let callOptions = { ... };
// Generate / Retrieve the encrypted tokens.
const key = 'abc123...';
const credentials = {
accountToken: createToken(account, key),
fromToken: createToken('sip:' + account, key),
toToken: createToken('sip:' + callee, key),
realm: 'realmAbc123...'
};
let callId = kandy.call.makeAnonymous(callee, credentials, callOptions);
States of a call.
(string)
: The call is on-going.
(string)
: The call has been established and is waiting for a user response.
(string)
: The call has been terminated.
(string)
: The call has been put on hold locally.
(string)
: The call has been put on hold remotely.
kandy.on('call:stateChange', function(callInfo) {
if(callInfo.state === kandy.call.states.ENDED) {
// Call has ended.
}
});
State of the media connection within a call.
(string)
: A new media connection process has started.
(string)
: Media is searching for a connection.
(string)
: Media has found a connection, but may still be searching for a better connection to use.
(string)
: Media has finished searching and been established. Audio/video should now be flowing on the call.
(string)
: Media was not able to find a connection. Audio/video will not flow.
(string)
: The media connection has lost its connection and is trying to recover.
(string)
: The media connection has shut down.
Start local video stream for an ongoing call.
(string)
Id of the call being acted on.
(Object?)
options Options for the video stream.
Name | Description |
---|---|
options.videoResolution Object?
|
videoResolution The video resolution configuation object. |
options.videoResolution.height number?
|
height The height of the outoing video in pixels. |
options.videoResolution.width number?
|
width The width of the outoing video in pixels. |
Starts sharing a screen over a call.
(string)
Id of the call being acted on.
(Object)
Name | Description |
---|---|
options.mediaSourceId string
|
Id of the media screen to share. |
options.height Number
(default 768 )
|
The height of the video stream to send. |
options.width Number
(default 1024 )
|
The width of the video stream to send. |
options.frameRate Number
(default 15 )
|
The number of frames per second to request. |
A call's state has changed.
(Object)
Name | Description |
---|---|
params.callId string
|
The Id of the call. |
params.state string
|
New state of the call. |
params.transition Object
|
Information about the state change. |
params.transition.code number
|
Code representing the reason for the state change. |
params.transition.reasonText string
|
Explanation of the status code. |
params.transition.oldState string
|
The previous state of the call. |
kandy.on('call:stateChange', function(params) {
// We are now in call with another user, so update our app to show it.
if(params.state === kandy.call.states.IN_CALL) {
renderCall(kandy.call.getById(params.callId));
}
});
An error has occurred with a call.
(Object)
Name | Description |
---|---|
params.callId string
|
The id of the call. |
params.error KandyError
|
The Kandy error object. |
Media
Kandy's media features are used to control WebRTC Media Devices.
Media functions are namespaced beneath 'media' on the returned Kandy object.
Sets the selected devices as the default devices. They will be used for audio output for future calls. Changing speaker is supported on browser's that support HTMLMediaElement.setSinkId().
// Set only the default microphone and camera.
kandy.media.setDefaultDevices({
camera: 'abc123...',
microphone: 'def456...'
});
Retrieves the available media devices for use.
Connectivity
Kandy's connection feature is used to connect and maintain connections between the SDK and one or more backend servers.
Connectivity functions are namespaced beneath 'connectivity' on the returned Kandy object.
Notification
Registers a device token for push notifications.
(Object)
Name | Description |
---|---|
params.deviceToken string
|
The device token to be registered. |
params.services Array<string>
|
Array of services to register for. |
params.pushProvider string
|
The push provider, can be either 'apple' or 'google'. |
params.clientCorrelator string
|
Unique identifier for a client device. |
Deregisters for push notifications.
An error occured with push notifications.
(Object)
Name | Description |
---|---|
params.error KandyError
|
The Kandy error object. |
params.channel string
|
The channel for the notification. |
sdpHandlers
A List of handlers for manipulating the SDP Object
In some scenarios it's necessary to remove certain codecs being offered by the SDK to the remote party. While creating an SDP handler would allow a user to perform this type of manipulation, it is a non-trivial task that requires in-depth knowledge of WebRTC SDP.
To facilitate this common task, the SDK provides a codec removal handler that can be used for this purpose.
The SDP handlers are exposed on the entry point of the SDK. They need to be added to the list of SDP handlers via configuration on creation of a Kandy instance.
import createKandy from 'kandy';
const codecRemover = createKandy.sdpHandlers.createCodecRemover(['VP8', 'VP9'])
const kandy = createKandy({
call: {
sdpHandlers: [codecRemover]
}
})
Logger
The internal logger used to provide information about the SDK's behaviour.
Provide a log level as part of the SDK configuration (see configs.logs
) to use the logger.
Possible levels for the SDK logger.
(string)
: Logs nothing.
(string)
: Only log unhandled errors.
(string)
: Log issues that may cause problems or unexpected behaviour.
(string)
: Log useful information and messages to indicate the SDK's internal operations.
(string)
: Log information to help diagnose problematic behaviour.
Config
An interface for getting and updating the configuration Object.
KandyError
The Kandy error object. Provides information about an error that occurred in the SDK.
AudioBridge
Kandy's audio bridge feature allows multiple audio calls to be bridged together for a local three-way call.
Audio bridge functions are namespaced beneath 'audioBridge' on the returned Kandy object.
An error occurred while performing an audio bridge operation.
(Object)
Name | Description |
---|---|
params.error KandyError
|
The Kandy error object. |