Class: ArviaChat

ArviaChat

ArviaChat

new ArviaChat(projectId)

Constructor for Arvia Chat.
Parameters:
Name Type Description
projectId string ID of your arvia.chat project. You can find this in your project overview on your arvia.chat account.
Returns:
Arvia Chat instance
Type
ArviaChat
Example
var arviaChat = new ArviaChat('5b4f145ac4dbc95dcf926a52');

Methods


<static> close()

Disconnect and terminate the chat interface.
Example
arviaChat.close();

<static> connect()

Connect and join the room.
Example
arviaChat.connect();

<static> disconnect()

Disconnect and exit the room.
Example
arviaChat.disconnect();

<static> getAuthentication()

Get authentication object.
Returns:
The authentication object set by the setAuthentication method
Type
object
Example
arviaChat.getAuthentication();
// returns {token: awqwr7632s76xfew68rhb68hwf8et}

<static> getCamera()

Get the outgoing video stream source device id .
Returns:
false or Camera Id of the outgoing video stream source.
Type
boolean | string
Example
arviaChat.getCamera();

<static> getDefaultNotificationsEnabled()

Get if the default notifications are enabled or not.
Returns:
If returns true, default notifications are enabled. If returns false, default notifications are disabled.
Type
boolean
Example
arviaChat.getDefaultNotificationsEnabled();
// returns true

<static> getDeviceInfo()

Get device info. Audio/video input and output sources.
Returns:
Device info object which includes audio and video sources.
Type
object
Example
arviaChat.getDeviceInfo();
// ArviaChatEvent.DEVICE_INFO event is dispatched when device info is generated.
arviaChat.on(ArviaChatEvent.DEVICE_INFO, 
  function (e) {
    console.log(e);
  }
);

<static> getDynamicRoomName()

Get room name.
Returns:
The room name set by the setDynamicRoomName method.
Type
string
Example
arviaChat.getDynamicRoomName();
// returns 'my-room'

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

<static> getEndCallButtonVisibility()

Get visibility status of end call button.
Returns:
The visibility status of end call button set by the setEndCallButtonVisibility method.
Type
boolean
Example
arviaChat.getEndCallButtonVisibility();
// returns true

<static> getLocalMediaButtonsVisibility()

Get local media buttons visibility status.
Returns:
The local media buttons visibility status set by the setLocalMediaButtonsVisibility method
Type
boolean
Example
arviaChat.getLocalMediaButtonsVisibility();
// returns true

<static> getMediaMessageButtonVisibility()

Get visibility status of media message button.
Returns:
The visibility status of media message button set by the setMediaMessageButtonVisibility method.
Type
boolean
Example
arviaChat.getMediaMessageButtonVisibility();
// returns true

<static> getMessageBoxVisibility()

Get visibility status of message box.
Returns:
The visibility status of message box set by the setMessageBoxVisibility method.
Type
boolean
Example
arviaChat.getMessageBoxVisibility();
// returns true

<static> getMicrophone()

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

<static> getRemoteMediaButtonsVisibility()

Get visibility status of remote users' media options buttons.
Returns:
The visibility status of remote users' media options buttons set by the setRemoteMediaButtonsVisibility method
Type
boolean
Example
arviaChat.getRemoteMediaButtonsVisibility();
// returns true

<static> getRoomName()

Get room name.
Returns:
The room name set by the setRoomName method.
Type
string
Example
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')

<static> getTestUser()

Get test status of this user.
Returns:
If true, this is a test user.
Type
boolean
Example
arviaChat.getTestUser();
// returns true

<static> getUserCount()

Get the number of users in the room.
Returns:
The number of users in the room.
Type
number
Example
arviaChat.getUserCount();
// returns 2

<static> getUserDetails()

Get user info.
Returns:
User details set by the setUserDetails method
Type
string
Example
arviaChat.getUserDetails();
// returns 'Calling from San Jose. Interested in annual contracts. Requests more info about pricing'

<static> getUserEmail()

Get user email.
Returns:
The user email set by the setUserEmail method
Type
string
Example
arviaChat.getUserEmail();
// returns 'ame@example.com'

<static> getUserId()

Get user id of this user.
Returns:
userId The user id set by the setUserId method.
Type
string
Example
arviaChat.getUserId();
// returns '12345'

<static> getUserName()

Get user name.
Returns:
The user name set by the setUserName method
Type
string
Example
arviaChat.getUserName();
// returns 'John Smith'

<static> getUsers()

Returns:
[object]

<static> getUserTags()

Get user tags.
Returns:
The user tags set by the setUserTags method
Type
Array.<string>
Example
arviaChat.getUserTags();
// returns ['Speaks-English', 'From-USA', '25-year-old']

<static> getUserTel()

Get user telephone number.
Returns:
The telephone number set by the setUserTel method
Type
string
Example
arviaChat.getUserTel();
// returns '+1 (123) 456 78 90'

<static> getVideoUserNamesVisibility()

Get visibility status of the user names on videos.
Returns:
The visibility status of the user names on videos set by the setVideoUserNamesVisibility method
Type
boolean
Example
arviaChat.getVideoUserNamesVisibility();
// returns true

<static> init(targetElement, serverURL, mediaServerURL)

Create the chat interface in the target div element.
Parameters:
Name Type Description
targetElement string | object Id (or DOM Object) of the target div element
serverURL string Alternative server url
mediaServerURL string Alternative media server url
Example
arviaChat.init('arviaChatDiv');

<static> openSettings()

Open settings window.
Example
arviaChat.openSettings();

<static> resize()

Call this method to update chat if the size of the target div element is changed.
Example
arviaChat.resize();

<static> setAuthentication(authentication)

Set authentication object.
Parameters:
Name Type Description
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.
Example
arviaChat.setAuthentication({token: awqwr7632s76xfew68rhb68hwf8et});

<static> setCamera(camera)

Set the outgoing video stream source device.
Parameters:
Name Type Description
camera boolean | string True/False or Camera Id to enable or disable video stream. Available Camera Ids can be obtained by the getDeviceInfo method.
Example
arviaChat.setCamera(true);

<static> setDefaultNotificationsEnabled(enabled)

Enable or disable default notifications which are sent by the SDK.
Parameters:
Name Type Description
enabled boolean If set to true, default notifications are enabled. If false, default notifications are disabled.
Example
arviaChat.setDefaultNotificationsEnabled(true);

<static> setDynamicRoomName(roomName)

Set dynamic room name.
Parameters:
Name Type Description
roomName string The dynamic room name suffix to connect and join
Example
arviaChat.setDynamicRoomName('my-room');

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

<static> setEndCallButtonVisibility(visible)

Set visibility status of end call button.
Parameters:
Name Type Description
visible boolean If set to true, end call button will be visible. If set to false, end call button will be hidden.
Example
arviaChat.setEndCallButtonButtonVisibility(true);

<static> setLocalMediaButtonsVisibility(visible)

Set local media buttons visibility status.
Parameters:
Name Type Description
visible boolean If set to true, camera and microphone buttons will be visible. If set to false, camera and microphone buttons will be hidden.
Example
arviaChat.setLocalMediaButtonsVisibility(true);

<static> setMediaMessageButtonVisibility(visible)

Set visibility status of media message button.
Parameters:
Name Type Description
visible boolean If set to true, media message button will be visible. If set to false, media message button will be hidden.
Example
arviaChat.setMediaMessageButtonVisibility(true);

<static> setMessageBoxVisibility(visible)

Set visibility status of message box.
Parameters:
Name Type Description
visible boolean If set to true, message box will be visible. If set to false, message box will be hidden.
Example
arviaChat.setMessageBoxVisibility(true);

<static> setMicrophone(microphone)

Set the outgoing audio stream source device.
Parameters:
Name Type Description
microphone boolean | string True/False or Microphone Id to enable or disable video stream. Available Microphone Ids can be obtained by the getDeviceInfo method.
Example
arviaChat.setMicrophone(true);

<static> setRemoteMediaButtonsVisibility(visible)

Set visibility status of remote users' media options buttons.
Parameters:
Name Type Description
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.
Example
arviaChat.setRemoteMediaButtonsVisibility(true);

<static> setRoomName(roomName)

Set room name.
Parameters:
Name Type Description
roomName string The room name to connect and join
Example
// 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.

<static> setTestUser(testUser)

Set test user.
Parameters:
Name Type Description
testUser boolean Set this to true while development only.
Example
arviaChat.setTestUser(true);
// Test users will connect to a test room automatically

<static> setUserDetails(userDetails)

Set user info.
Parameters:
Name Type Description
userDetails string Any details you want to add to this user
Example
arviaChat.setUserDetails('Calling from San Jose. Interested in annual contracts. Requests more info about pricing.');

<static> setUserEmail(userEmail)

Set user email.
Parameters:
Name Type Description
userEmail string User email that you can assign to your user
Example
arviaChat.setUserEmail('name@example.com');

<static> setUserId(userId)

Set user id.
Parameters:
Name Type Description
userId string Uniqe user id of the user. You can use this user id track this user.
Default Value:
  • {string} Random string
Example
arviaChat.setUserId('12345');

<static> setUserName(userName)

Set user name.
Parameters:
Name Type Description
userName string Name that you can assign to your user
Example
arviaChat.setUserName('John Smith');

<static> setUserTags(userTags)

Set user tags.
Parameters:
Name Type Description
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.
Example
arviaChat.setUserTags(['Speaks-English', 'From-USA', '25-year-old']);

<static> setUserTel(userTel)

Set user telephone number.
Parameters:
Name Type Description
userTel string Telephone number that you can assign to your user
Example
arviaChat.setUserTel('+1 (123) 456 78 90');

<static> setVideoUserNamesVisibility(visible)

Set visibility of the user names on videos.
Parameters:
Name Type Description
visible boolean If set to true, user names will be shown on videos. If set to false, user names on videos will be hidden.
Example
arviaChat.setVideoUserNamesVisibility(true);

<static> shareScreen(share)

Start or stop sharing screen.
Parameters:
Name Type Description
share boolean If set to true, screen sharing starts. If set to false, sceeen sharing stops.
Example
arviaChat.shareScreen(true);

<static> showNotification(text, type)

Show a notification using the Arvia Chat's built in notifications.
Parameters:
Name Type Description
text string Text to display
type string Type of the notification ('base', 'success', 'error', 'info', 'warn')
Example
arviaChat.showNotification('Please wait while connecting...');

<static> stopAudioVideo()

Stops broadcasting audio and video.
Example
arviaChat.stopAudioVideo();

<static> switchAudioOutput()

Switch the audio output to next available speaker/earphone.
Example
arviaChat.switchAudioOutput();

<static> switchCamera()

Switch the video input to next available camera.
Example
arviaChat.switchCamera();

<static> switchMicrophone()

Switch the audio input to next available microphone.
Example
arviaChat.switchMicrophone();

<static> takeSnapshot(allParticipants)

Take snapshot
Parameters:
Name Type Description
allParticipants boolean Take all participants snapshot

<static> toggleScreenSharing()

Toggles sharing screen start/stop.
Example
arviaChat.toggleScreenSharing();

<static> turnOffCamera()

Turn off camera and put outgoing video on hold.
Example
arviaChat.turnOffCamera();

<static> turnOffMicrophone()

Turn off microphone and mute your audio.
Example
arviaChat.turnOffMicrophone();

<static> turnOnCamera()

Turn on camera and broadcast your video.
Example
arviaChat.turnOnCamera();

<static> turnOnMicrophone()

Turn on microphone and broadcast your audio.
Example
arviaChat.turnOnMicrophone();