Skip to content

Latest commit

 

History

History
1507 lines (970 loc) · 27.4 KB

reference.md

File metadata and controls

1507 lines (970 loc) · 27.4 KB

Table of Contents

ArviaChat

Constructor for Arvia Chat.

Parameters

  • projectId string ID of your arvia.chat project. You can find this in your project overview on your arvia.chat account.

Examples

var arviaChat = new ArviaChat('5b4f145ac4dbc95dcf926a52');

Returns ArviaChat Arvia Chat instance

setUserId

Set user id.

Parameters

  • userId string Uniqe user id of the user. You can use this user id track this user.

Examples

arviaChat.setUserId('12345');

getUserId

Get user id of this user.

Examples

arviaChat.getUserId();
// returns '12345'

Returns string userId The user id set by the setUserId method.

setTestUser

Set test user.

Parameters

  • testUser boolean Set this to true while development only.

Examples

arviaChat.setTestUser(true);
// Test users will connect to a test room automatically

getTestUser

Get test status of this user.

Examples

arviaChat.getTestUser();
// returns true

Returns boolean If true, this is a test user.

setRoomName

Set room name.

Parameters

  • roomName string The room name to connect and join

Examples

// Top-level room
arviaChat.setRoomName('my-room');

// Dynamic room ([projectId]/[roomName])
arviaChat.setRoomName('5b4f145ac4dbc95dcf926a52/my-room');
// You can also set the dynamic room name using setDynamicRoomName method. setDynamicRoomName method only expects the room name as the parameter. Project id is added automatically as a prefix.

getRoomName

Get room name.

Examples

arviaChat.getRoomName();
// returns 'my-room' if the room is a top-level room

// if current room is a dynamic room, this method returns [projectId]/[roomName] (E.g: '5b4f145ac4dbc95dcf926a52/my-room')

Returns string The room name set by the setRoomName method.

setDynamicRoomName

Set dynamic room name.

Parameters

  • roomName string The dynamic room name suffix to connect and join

Examples

arviaChat.setDynamicRoomName('my-room');

// Actual room name will be [projectId]/[roomName] (E.g: '5b4f145ac4dbc95dcf926a52/my-room')

getDynamicRoomName

Get room name.

Examples

arviaChat.getDynamicRoomName();
// returns 'my-room'

// If current room is not a dynamic room, this method returns empty string.

Returns string The room name set by the setDynamicRoomName method.

setUserName

Set user name.

Parameters

  • userName string Name that you can assign to your user

Examples

arviaChat.setUserName('John Smith');

getUserName

Get user name.

Examples

arviaChat.getUserName();
// returns 'John Smith'

Returns string The user name set by the setUserName method

setUserEmail

Set user email.

Parameters

  • userEmail string User email that you can assign to your user

Examples

arviaChat.setUserEmail('name@example.com');

getUserEmail

Get user email.

Examples

arviaChat.getUserEmail();
// returns 'ame@example.com'

Returns string The user email set by the setUserEmail method

setUserTel

Set user telephone number.

Parameters

  • userTel string Telephone number that you can assign to your user

Examples

arviaChat.setUserTel('+1 (123) 456 78 90');

getUserTel

Get user telephone number.

Examples

arviaChat.getUserTel();
// returns '+1 (123) 456 78 90'

Returns string The telephone number set by the setUserTel method

setUserDetails

Set user info.

Parameters

  • userDetails string Any details you want to add to this user

Examples

arviaChat.setUserDetails('Calling from San Jose. Interested in annual contracts. Requests more info about pricing.');

getUserDetails

Get user info.

Examples

arviaChat.getUserDetails();
// returns 'Calling from San Jose. Interested in annual contracts. Requests more info about pricing'

Returns string User details set by the setUserDetails method

setUserTags

Set user tags.

Parameters

  • userTags Array<string> The user tags to group or classify the user. Users can be assigned to specific agents by assigning the same tags to the users and the agents which you add to your projects or rooms on your Arvia Chat account center.

Examples

arviaChat.setUserTags(['Speaks-English', 'From-USA', '25-year-old']);

getUserTags

Get user tags.

Examples

arviaChat.getUserTags();
// returns ['Speaks-English', 'From-USA', '25-year-old']

Returns Array<string> The user tags set by the setUserTags method

setAuthentication

Set authentication object.

Parameters

  • authentication object The authentication object which includes the required login credentials (or token, session id, etc.) to validate your users before allowing them to join your rooms. You need to set the authentication url for your project on your Arvia account center. The authentication url must be a script under your validated website platform.Variables in this authentication object, will be posted to the authentication url which is set on your account center. On a valid request, your authentication script should return a json string including a 'success' parameter set to true. Any other respone will be considered as a failed authentication.Please take a look at the Autherntication tab on your Arvia account center for more information and examples.

Examples

arviaChat.setAuthentication({token: awqwr7632s76xfew68rhb68hwf8et});

getAuthentication

Get authentication object.

Examples

arviaChat.getAuthentication();
// returns {token: awqwr7632s76xfew68rhb68hwf8et}

Returns object The authentication object set by the setAuthentication method

getUserCount

Get the number of users in the room.

Examples

arviaChat.getUserCount();
// returns 2

Returns number The number of users in the room.

setLocalMediaButtonsVisibility

Set local media buttons visibility status.

Parameters

  • visible boolean If set to true, camera and microphone buttons will be visible. If set to false, camera and microphone buttons will be hidden.

Examples

arviaChat.setLocalMediaButtonsVisibility(true);

getLocalMediaButtonsVisibility

Get local media buttons visibility status.

Examples

arviaChat.getLocalMediaButtonsVisibility();
// returns true

Returns boolean The local media buttons visibility status set by the setLocalMediaButtonsVisibility method

setRemoteMediaButtonsVisibility

Set visibility status of remote users' media options buttons.

Parameters

  • visible boolean If set to true, options button, which toggles the incoming video, incoming audio and fullscreen buttos, will be visible. If set to false, these options button will be hidden.

Examples

arviaChat.setRemoteMediaButtonsVisibility(true);

getRemoteMediaButtonsVisibility

Get visibility status of remote users' media options buttons.

Examples

arviaChat.getRemoteMediaButtonsVisibility();
// returns true

Returns boolean The visibility status of remote users' media options buttons set by the setRemoteMediaButtonsVisibility method

setMessageBoxVisibility

Set visibility status of message box.

Parameters

  • visible boolean If set to true, message box will be visible. If set to false, message box will be hidden.

Examples

arviaChat.setMessageBoxVisibility(true);

getMessageBoxVisibility

Get visibility status of message box.

Examples

arviaChat.getMessageBoxVisibility();
// returns true

Returns boolean The visibility status of message box set by the setMessageBoxVisibility method.

setMediaMessageButtonVisibility

Set visibility status of media message button.

Parameters

  • visible boolean If set to true, media message button will be visible. If set to false, media message button will be hidden.

Examples

arviaChat.setMediaMessageButtonVisibility(true);

getMediaMessageButtonVisibility

Get visibility status of media message button.

Examples

arviaChat.getMediaMessageButtonVisibility();
// returns true

Returns boolean The visibility status of media message button set by the setMediaMessageButtonVisibility method.

setEndCallButtonVisibility

Set visibility status of end call button.

Parameters

  • visible boolean If set to true, end call button will be visible. If set to false, end call button will be hidden.

Examples

arviaChat.setEndCallButtonButtonVisibility(true);

getEndCallButtonVisibility

Get visibility status of end call button.

Examples

arviaChat.getEndCallButtonVisibility();
// returns true

Returns boolean The visibility status of end call button set by the setEndCallButtonVisibility method.

setDefaultNotificationsEnabled

Enable or disable default notifications which are sent by the SDK.

Parameters

  • enabled boolean If set to true, default notifications are enabled. If false, default notifications are disabled.

Examples

arviaChat.setDefaultNotificationsEnabled(true);

getDefaultNotificationsEnabled

Get if the default notifications are enabled or not.

Examples

arviaChat.getDefaultNotificationsEnabled();
// returns true

Returns boolean If returns true, default notifications are enabled. If returns false, default notifications are disabled.

getDeviceInfo

Get device info. Audio/video input and output sources.

Examples

arviaChat.getDeviceInfo();
// ArviaChatEvent.DEVICE_INFO event is dispatched when device info is generated.
arviaChat.on(ArviaChatEvent.DEVICE_INFO, 
  function (e) {
    console.log(e);
  }
);

Returns object Device info object which includes audio and video sources.

init

Create the chat interface in the target div element.

Parameters

  • targetElement (string | object) Id (or DOM Object) of the target div element

Examples

arviaChat.init('arviaChatDiv');

connect

Connect and join the room.

Examples

arviaChat.connect();

switchAudioOutput

Switch the audio output to next available speaker/earphone.

Examples

arviaChat.switchAudioOutput();

switchMicrophone

Switch the audio input to next available microphone.

Examples

arviaChat.switchMicrophone();

getMicrophone

Get the outgoing audio stream source device id .

Returns (boolean | string) false or Microphone Id of the outgoing audio stream source. arviaChat.getMicrophone();

switchCamera

Switch the video input to next available camera.

Examples

arviaChat.switchCamera();

getCamera

Get the outgoing video stream source device id .

Examples

arviaChat.getCamera();

Returns (boolean | string) false or Camera Id of the outgoing video stream source.

toggleScreenSharing

Toggles sharing screen start/stop.

Examples

arviaChat.toggleScreenSharing();

close

Disconnect and terminate the chat interface.

Parameters

  • closeRoom

Examples

arviaChat.close();

setMicrophone

Set the outgoing audio stream source device.

Parameters

  • microphone (boolean | string) True/False or Microphone Id to enable or disable video stream. Available Microphone Ids can be obtained by the getDeviceInfo method.

Examples

arviaChat.setMicrophone(true);

setCamera

Set the outgoing video stream source device.

Parameters

  • camera (boolean | string) True/False or Camera Id to enable or disable video stream. Available Camera Ids can be obtained by the getDeviceInfo method.

Examples

arviaChat.setCamera(true);

shareScreen

Start or stop sharing screen.

Parameters

  • share boolean If set to true, screen sharing starts. If set to false, sceeen sharing stops.

Examples

arviaChat.shareScreen(true);

stopAudioVideo

Stops broadcasting audio and video.

Examples

arviaChat.stopAudioVideo();

disconnect

Disconnect and exit the room.

Examples

arviaChat.disconnect();

turnOnMicrophone

Turn on microphone and broadcast your audio.

Examples

arviaChat.turnOnMicrophone();

turnOffMicrophone

Turn off microphone and mute your audio.

Examples

arviaChat.turnOffMicrophone();

turnOnCamera

Turn on camera and broadcast your video.

Examples

arviaChat.turnOnCamera();

turnOffCamera

Turn off camera and put outgoing video on hold.

Examples

arviaChat.turnOffCamera();

resize

Call this method to update chat if the size of the target div element is changed.

Examples

arviaChat.resize();

showNotification

Show a notification using the Arvia Chat's built in notifications.

Parameters

  • text string Text to display
  • type string Type of the notification ('base', 'success', 'error', 'info', 'warn')

Examples

arviaChat.showNotification('Please wait while connecting...');

ArviaChatEvent.AUTHENTICATION_ERROR

Dispatched if the authentication fails.

Examples

arviaChat.on(ArviaChatEvent.AUTHENTICATION_ERROR, 
 function (e) {
   arviaChat.showNotification('Authentication failed.');
   console.log(e);
 }
);

ArviaChatEvent.CONNECT

Dispatched when connected.

Examples

arviaChat.on(ArviaChatEvent.CONNECT, 
 function (e) {
   arviaChat.showNotification('Connected to room');
 }
);

ArviaChatEvent.CONNECT_ERROR

Dispatched when connect failed.

Examples

arviaChat.on(ArviaChatEvent.CONNECT_ERROR, 
 function (e) {
   arviaChat.showNotification('Connect error!');
   console.log(e);
 }
);

ArviaChatEvent.DISCONNECT

Dispatched when disconnected.

Examples

arviaChat.on(ArviaChatEvent.DISCONNECT, 
 function (e) {
   arviaChat.showNotification('Disconnected from server!');
 }
);

ArviaChatEvent.JOIN_REQUEST

Dispatched when the room is locked, someone wants to join the room and you are the room agent.

Examples

arviaChat.on(ArviaChatEvent.JOIN_REQUEST, 
 function (e) {
   arviaChat.showNotification('Someone wants to join the room');
   console.log(e);
 }
);

ArviaChatEvent.JOIN_ROOM_ERROR

Dispatched when you can not enter the room.

Examples

arviaChat.on(ArviaChatEvent.JOIN_ROOM_ERROR, 
 function (e) {
   arviaChat.showNotification('Can not join the room');
   console.log(e);
 }
);

ArviaChatEvent.USER_JOIN

Dispatched when a user joins room.

Examples

arviaChat.on(ArviaChatEvent.USER_JOIN, 
 function (e) {
   arviaChat.showNotification('Someone joined the room');
   console.log(e);
 }
);

ArviaChatEvent.USER_LIST

Dispatched when the user joins or leaves the room.

Examples

arviaChat.on(ArviaChatEvent.USER_LIST, 
 function (e) {
   arviaChat.showNotification('User list updated');
   console.log(e);
 }
);

ArviaChatEvent.WAITING_FOR_PERMISSION

Dispatched when the room you are trying to join is locked and waiting for the agent to let you in.

Examples

arviaChat.on(ArviaChatEvent.WAITING_FOR_PERMISSION, 
 function (e) {
   arviaChat.showNotification('Waiting for permission from the room agent');
   console.log(e);
 }
);

ArviaChatEvent.ROOM_FULL

Dispatched when the room you are trying to join is full.

Examples

arviaChat.on(ArviaChatEvent.ROOM_FULL, 
 function (e) {
   arviaChat.showNotification('This room is full');
   console.log(e);
 }
);

ArviaChatEvent.DEVICE_INFO

Dispatched after the getDeviceInfo is called and when the device info is generated.

Examples

arviaChat.getDeviceInfo();
// ArviaChatEvent.DEVICE_INFO event is dispatched when device info is generated.
arviaChat.on(ArviaChatEvent.DEVICE_INFO, 
  function (e) {
    console.log(e);
  }
);

ArviaChatEvent.DEVICE_INFO_ERROR

Dispatched after the getDeviceInfo is called and when the device info can not be generated.

Examples

arviaChat.getDeviceInfo();
// ArviaChatEvent.DEVICE_INFO_ERROR event is dispatched when device info can not be generated.
arviaChat.on(ArviaChatEvent.DEVICE_INFO_ERROR, 
  function (e) {
    console.log('Can not get device info!');
  }
);

ArviaChatEvent.LOCAL_STREAM

Dispatched when the camera access granted.

Examples

arviaChat.on(ArviaChatEvent.LOCAL_STREAM, 
 function (e) {
   arviaChat.showNotification('Got video stream from the camera.');
   console.log(e);
 }
);

ArviaChatEvent.LOCAL_STREAM_ERROR

Dispatched if the camera can not be accessed.

Examples

arviaChat.on(ArviaChatEvent.LOCAL_STREAM_ERROR, 
 function (e) {
   arviaChat.showNotification('Can not access camera.');
   console.log(e);
 }
);

ArviaChatEvent.SCREEN_SHARE

Dispatched when the screen access granted.

Examples

arviaChat.on(ArviaChatEvent.SCREEN_SHARE, 
 function (e) {
   arviaChat.showNotification('Got screen display to share.');
   console.log(e);
 }
);

ArviaChatEvent.SCREEN_SHARE_ERROR

Dispatched if the screen can not be shared.

Examples

arviaChat.on(ArviaChatEvent.SCREEN_SHARE_ERROR, 
 function (e) {
   arviaChat.showNotification('Can not get screen display.');
   console.log(e);
 }
);

ArviaChatEvent.MESSAGE

Dispatched when a message is received.

Examples

arviaChat.on(ArviaChatEvent.MESSAGE, 
 function (e) {
   arviaChat.showNotification('Message received.');
   console.log(e.detail.userName);
   console.log(e.detail.userId);
   console.log(e.detail.message);
   console.log(e.detail.date);
 }
);

ArviaChatEvent.CONNECTING

Dispatched when trying to connect.

Examples

arviaChat.on(ArviaChatEvent.CONNECTING, 
 function (e) {
   arviaChat.showNotification('Please wait while connecting...');
 }
);