= Clique JS Client SDK
== Installing Clique JS Client SDK
Clique JS Client SDK ( "Clique Client" ) is available via npm
npm install clique-api-client-js
or bower
bower install clique-api-client-js
If you use webpack, you can add Clique Client to your project as follows:
import CliqueClient from "clique-api-client-js";
Or just use a pre-built version (client.build.js). jQuery is required.
== Creating Clique Client Instance
Here is an example of Clique Client instantiation:
var cliqueClient = new CliqueClient({
api_endpoint: 'https://clique-core.caw.me/api/v2',
websocket_endpoint: 'https://clique-core.caw.me/',
user_uuid: "<clique_user_object_uuid>",
user_token: "<clique_user_object_access_token>",
wss_port: 443,
iceServers: [
{
url:'stun:stun.l.google.com:19302'
},
{
url: "turn:turn.caw.me:443",
username: "<turn_server_username>",
credential: "<turn_server_pass>"
}
]
});
A single Clique Client instance is connected to a specific Clique user, so user_uuid and user_token parameters are required.
You can get Clique user object via Clique-core REST API using your API key provided by Clique.
== Clique Client instance methods
=== createConference(options): Promise
Creates a new conference and joins it. Returns a Promise.
options - parameter: p2p, type: bool; determines whether your conference will be set up as peer to peer ( p2p ) or based on a Clique cloud server
cliqueClient.createConference({p2p: false})
=== joinConference(conference_id): Promise
Joins a conference with a given conference_id. Returns a Promise
cliqueClient.joinConference('74416d26-fe68-4773-8e8f-307eb7eafd22')
=== localMute(conference_id)
Mutes the user's microphone localy
cliqueClient.localMute('74416d26-fe68-4773-8e8f-307eb7eafd22')
=== localUnmute(conference_id)
Unmutes the user's microphone localy
cliqueClient.localUnmute('74416d26-fe68-4773-8e8f-307eb7eafd22')
=== localVolume(conference_id, volume)
Sets local volume level (from 0 to 100)
cliqueClient.localVolume('74416d26-fe68-4773-8e8f-307eb7eafd22', 50)
=== muteUser(user_sip_id)
Mutes the user with a given user_sip_id; available for conference creator (moderator) only
cliqueClient.muteUser('6b673598-6bb7-4b36-b54f-5bec18443c19')
=== unmuteUser(user_sip_id)
Unmutes the user with a given user_sip_id; available for conference creator (moderator) only
cliqueClient.unmuteUser('6b673598-6bb7-4b36-b54f-5bec18443c19')
=== kickUser(user_sip_id)
Kicks the user with a given user_sip_id out of the conference; available for conference creator (moderator) only
cliqueClient.kickUser('6b673598-6bb7-4b36-b54f-5bec18443c19')
=== dropCall(user_sip_id)
Disconnects the phone call with a given user_sip_id
cliqueClient.dropCall('6b673598-6bb7-4b36-b54f-5bec18443c19')
=== lock(conference_id)
Locks the given conference ( no new users can join ); available for conference creator (moderator) only
cliqueClient.lock('74416d26-fe68-4773-8e8f-307eb7eafd25')
=== unlock(conference_id)
Unlocks the given conference ( allow new users to join ); available for conference creator (moderator) only
cliqueClient.unlock('74416d26-fe68-4773-8e8f-307eb7eafd25')
=== setgrace(conference_id, period)
Sets a grace period for ending the conference. Period is a time delay in minutes of the conference destruction after the moderator leaves
If period = 0, conference would not be destroyed after the moderator leaves.
cliqueClient.setgrace('74416d26-fe68-4773-8e8f-307eb7eafd25', 5)
=== closeConference(conference_id)
Closes the user connection to the conference with a given conference_id
cliqueClient.closeConference('74416d26-fe68-4773-8e8f-307eb7eafd25')
=== getConfInfo(conference_id): Promise
Gets a conference object from the Clique REST API. Returns a promise. Look up GET /conferences/:id method in Clique-core API docs for more info
cliqueClient.getConfInfo('74416d26-fe68-4773-8e8f-307eb7eafd25')
=== updateConfInfo(conference_id, data): Promise
Updates a conference object via Clique REST API. Returns a promise. Look up PUT /conferences/:id method in Clique-core API docs for more info
cliqueClient.updateConfInfo('74416d26-fe68-4773-8e8f-307eb5eafd27', {meta: { custom_field: 'custom_value' }})
=== getConfSettings(conference_id): Promise
Gets a conference settings object from the Clique REST API. Returns a promise. Look up /conferences/:id/settings method in Clique-core API docs for more info
cliqueClient.getConfSettings('74416d26-fe68-4773-8e8f-307eb7eafd25')
=== confUserList(conference_id): Promise
Gets a hash map of users who are currently in the conference. Returns a promise. Look up /user-list-hash method in Clique-core API docs for more info.
cliqueClient.confUserList('74416d26-fe68-4773-8e8f-307eb7eafd25')
== Events handling
Clique Client provides multiple events via the websocket transport. For example, events with the info on who is joined or who is talking, etc.
You can subscribe to a specific event using the cliqueClient.on method
cliqueClient.on('start-talking', function(event) {
console.log(event);
})
.Events list (event_name{event_fields} - event_description):
- init {} - confirms that the CliqueClient has been initialized
- add-member {room, user} - user joined the conference with id 'room'
- del-member {room, user_id} - user with id = user_id left the conference with id room
- start-talking {room, user_id} - user with id = user_id started talking
- stop-talking {room, user_id} - user with id = user_id stopped talking
- mute-member {room, user_id} - user with id = user_id has been muted by the moderator
- unmute-member {room, user_id} - user with id = user_id has been unmuted by the moderator
- lock {room} - conference with a given conference_id has been locked by the moderator
- unlock {room} - conference with a given conference_id has been unlocked by the moderator
- kick-member {room, user_id} - user with id = user_id has been kicked by the moderator
- conference-create {room} - conference with a given conference_id started
- conference-destroy {room} - conference with target id ended
- call-status-amd {room, user_id} - call answering machine detected
- call-status {room, user_id, status} - call status changed
- setgrace {room} - conference grace period time delay has been changed
- start-recording {room} - conference recording started
- stop-recording {room} - conference recording stopped
- connected {} - triggered on websocket successful login
- disconnected {} - triggered on websocket disconnect
- room_join {room, user} - triggerd when the current user successfuly joined the conference with id = 'room'
- room_leave {room, message, error} - triggered when the user has been disconnected from conference 'room'
- error {code, error}