- ArviaChat
- setUserId
- getUserId
- setTestUser
- getTestUser
- setRoomName
- getRoomName
- setDynamicRoomName
- getDynamicRoomName
- setUserName
- getUserName
- setUserEmail
- getUserEmail
- setUserTel
- getUserTel
- setUserDetails
- getUserDetails
- setUserTags
- getUserTags
- setAuthentication
- getAuthentication
- getUserCount
- setLocalMediaButtonsVisibility
- getLocalMediaButtonsVisibility
- setRemoteMediaButtonsVisibility
- getRemoteMediaButtonsVisibility
- setMessageBoxVisibility
- getMessageBoxVisibility
- setMediaMessageButtonVisibility
- getMediaMessageButtonVisibility
- setEndCallButtonVisibility
- getEndCallButtonVisibility
- setDefaultNotificationsEnabled
- getDefaultNotificationsEnabled
- getDeviceInfo
- init
- connect
- switchAudioOutput
- switchMicrophone
- getMicrophone
- switchCamera
- getCamera
- toggleScreenSharing
- close
- setMicrophone
- setCamera
- shareScreen
- stopAudioVideo
- disconnect
- turnOnMicrophone
- turnOffMicrophone
- turnOnCamera
- turnOffCamera
- resize
- showNotification
- ArviaChatEvent.AUTHENTICATION_ERROR
- ArviaChatEvent.CONNECT
- ArviaChatEvent.CONNECT_ERROR
- ArviaChatEvent.DISCONNECT
- ArviaChatEvent.JOIN_REQUEST
- ArviaChatEvent.JOIN_ROOM_ERROR
- ArviaChatEvent.USER_JOIN
- ArviaChatEvent.USER_LIST
- ArviaChatEvent.WAITING_FOR_PERMISSION
- ArviaChatEvent.ROOM_FULL
- ArviaChatEvent.DEVICE_INFO
- ArviaChatEvent.DEVICE_INFO_ERROR
- ArviaChatEvent.LOCAL_STREAM
- ArviaChatEvent.LOCAL_STREAM_ERROR
- ArviaChatEvent.SCREEN_SHARE
- ArviaChatEvent.SCREEN_SHARE_ERROR
- ArviaChatEvent.MESSAGE
- ArviaChatEvent.CONNECTING
Constructor for Arvia Chat.
projectId
string ID of your arvia.chat project. You can find this in your project overview on your arvia.chat account.
var arviaChat = new ArviaChat('5b4f145ac4dbc95dcf926a52');
Returns ArviaChat Arvia Chat instance
Set user id.
userId
string Uniqe user id of the user. You can use this user id track this user.
arviaChat.setUserId('12345');
Get user id of this user.
arviaChat.getUserId();
// returns '12345'
Returns string userId The user id set by the setUserId method.
Set test user.
testUser
boolean Set this to true while development only.
arviaChat.setTestUser(true);
// Test users will connect to a test room automatically
Get test status of this user.
arviaChat.getTestUser();
// returns true
Returns boolean If true, this is a test user.
Set room name.
roomName
string The room name to connect and join
// 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.
Get room name.
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.
Set dynamic room name.
roomName
string The dynamic room name suffix to connect and join
arviaChat.setDynamicRoomName('my-room');
// Actual room name will be [projectId]/[roomName] (E.g: '5b4f145ac4dbc95dcf926a52/my-room')
Get room name.
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.
Set user name.
userName
string Name that you can assign to your user
arviaChat.setUserName('John Smith');
Get user name.
arviaChat.getUserName();
// returns 'John Smith'
Returns string The user name set by the setUserName method
Set user email.
userEmail
string User email that you can assign to your user
arviaChat.setUserEmail('name@example.com');
Get user email.
arviaChat.getUserEmail();
// returns 'ame@example.com'
Returns string The user email set by the setUserEmail method
Set user telephone number.
userTel
string Telephone number that you can assign to your user
arviaChat.setUserTel('+1 (123) 456 78 90');
Get user telephone number.
arviaChat.getUserTel();
// returns '+1 (123) 456 78 90'
Returns string The telephone number set by the setUserTel method
Set user info.
userDetails
string Any details you want to add to this user
arviaChat.setUserDetails('Calling from San Jose. Interested in annual contracts. Requests more info about pricing.');
Get user info.
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
Set user tags.
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.
arviaChat.setUserTags(['Speaks-English', 'From-USA', '25-year-old']);
Get user tags.
arviaChat.getUserTags();
// returns ['Speaks-English', 'From-USA', '25-year-old']
Returns Array<string> The user tags set by the setUserTags method
Set authentication object.
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.
arviaChat.setAuthentication({token: awqwr7632s76xfew68rhb68hwf8et});
Get authentication object.
arviaChat.getAuthentication();
// returns {token: awqwr7632s76xfew68rhb68hwf8et}
Returns object The authentication object set by the setAuthentication method
Get the number of users in the room.
arviaChat.getUserCount();
// returns 2
Returns number The number of users in the room.
Set local media buttons visibility status.
visible
boolean If set to true, camera and microphone buttons will be visible. If set to false, camera and microphone buttons will be hidden.
arviaChat.setLocalMediaButtonsVisibility(true);
Get local media buttons visibility status.
arviaChat.getLocalMediaButtonsVisibility();
// returns true
Returns boolean The local media buttons visibility status set by the setLocalMediaButtonsVisibility method
Set visibility status of remote users' media options buttons.
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.
arviaChat.setRemoteMediaButtonsVisibility(true);
Get visibility status of remote users' media options buttons.
arviaChat.getRemoteMediaButtonsVisibility();
// returns true
Returns boolean The visibility status of remote users' media options buttons set by the setRemoteMediaButtonsVisibility method
Set visibility status of message box.
visible
boolean If set to true, message box will be visible. If set to false, message box will be hidden.
arviaChat.setMessageBoxVisibility(true);
Get visibility status of message box.
arviaChat.getMessageBoxVisibility();
// returns true
Returns boolean The visibility status of message box set by the setMessageBoxVisibility method.
Set visibility status of media message button.
visible
boolean If set to true, media message button will be visible. If set to false, media message button will be hidden.
arviaChat.setMediaMessageButtonVisibility(true);
Get visibility status of media message button.
arviaChat.getMediaMessageButtonVisibility();
// returns true
Returns boolean The visibility status of media message button set by the setMediaMessageButtonVisibility method.
Set visibility status of end call button.
visible
boolean If set to true, end call button will be visible. If set to false, end call button will be hidden.
arviaChat.setEndCallButtonButtonVisibility(true);
Get visibility status of end call button.
arviaChat.getEndCallButtonVisibility();
// returns true
Returns boolean The visibility status of end call button set by the setEndCallButtonVisibility method.
Enable or disable default notifications which are sent by the SDK.
enabled
boolean If set to true, default notifications are enabled. If false, default notifications are disabled.
arviaChat.setDefaultNotificationsEnabled(true);
Get if the default notifications are enabled or not.
arviaChat.getDefaultNotificationsEnabled();
// returns true
Returns boolean If returns true, default notifications are enabled. If returns false, default notifications are disabled.
Get device info. Audio/video input and output sources.
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.
Create the chat interface in the target div element.
arviaChat.init('arviaChatDiv');
Connect and join the room.
arviaChat.connect();
Switch the audio output to next available speaker/earphone.
arviaChat.switchAudioOutput();
Switch the audio input to next available microphone.
arviaChat.switchMicrophone();
Get the outgoing audio stream source device id .
Returns (boolean | string) false or Microphone Id of the outgoing audio stream source. arviaChat.getMicrophone();
Switch the video input to next available camera.
arviaChat.switchCamera();
Get the outgoing video stream source device id .
arviaChat.getCamera();
Returns (boolean | string) false or Camera Id of the outgoing video stream source.
Toggles sharing screen start/stop.
arviaChat.toggleScreenSharing();
Disconnect and terminate the chat interface.
closeRoom
arviaChat.close();
Set the outgoing audio stream source device.
microphone
(boolean | string) True/False or Microphone Id to enable or disable video stream. Available Microphone Ids can be obtained by the getDeviceInfo method.
arviaChat.setMicrophone(true);
Set the outgoing video stream source device.
camera
(boolean | string) True/False or Camera Id to enable or disable video stream. Available Camera Ids can be obtained by the getDeviceInfo method.
arviaChat.setCamera(true);
Start or stop sharing screen.
share
boolean If set to true, screen sharing starts. If set to false, sceeen sharing stops.
arviaChat.shareScreen(true);
Stops broadcasting audio and video.
arviaChat.stopAudioVideo();
Disconnect and exit the room.
arviaChat.disconnect();
Turn on microphone and broadcast your audio.
arviaChat.turnOnMicrophone();
Turn off microphone and mute your audio.
arviaChat.turnOffMicrophone();
Turn on camera and broadcast your video.
arviaChat.turnOnCamera();
Turn off camera and put outgoing video on hold.
arviaChat.turnOffCamera();
Call this method to update chat if the size of the target div element is changed.
arviaChat.resize();
Show a notification using the Arvia Chat's built in notifications.
text
string Text to displaytype
string Type of the notification ('base', 'success', 'error', 'info', 'warn')
arviaChat.showNotification('Please wait while connecting...');
Dispatched if the authentication fails.
arviaChat.on(ArviaChatEvent.AUTHENTICATION_ERROR,
function (e) {
arviaChat.showNotification('Authentication failed.');
console.log(e);
}
);
Dispatched when connected.
arviaChat.on(ArviaChatEvent.CONNECT,
function (e) {
arviaChat.showNotification('Connected to room');
}
);
Dispatched when connect failed.
arviaChat.on(ArviaChatEvent.CONNECT_ERROR,
function (e) {
arviaChat.showNotification('Connect error!');
console.log(e);
}
);
Dispatched when disconnected.
arviaChat.on(ArviaChatEvent.DISCONNECT,
function (e) {
arviaChat.showNotification('Disconnected from server!');
}
);
Dispatched when the room is locked, someone wants to join the room and you are the room agent.
arviaChat.on(ArviaChatEvent.JOIN_REQUEST,
function (e) {
arviaChat.showNotification('Someone wants to join the room');
console.log(e);
}
);
Dispatched when you can not enter the room.
arviaChat.on(ArviaChatEvent.JOIN_ROOM_ERROR,
function (e) {
arviaChat.showNotification('Can not join the room');
console.log(e);
}
);
Dispatched when a user joins room.
arviaChat.on(ArviaChatEvent.USER_JOIN,
function (e) {
arviaChat.showNotification('Someone joined the room');
console.log(e);
}
);
Dispatched when the user joins or leaves the room.
arviaChat.on(ArviaChatEvent.USER_LIST,
function (e) {
arviaChat.showNotification('User list updated');
console.log(e);
}
);
Dispatched when the room you are trying to join is locked and waiting for the agent to let you in.
arviaChat.on(ArviaChatEvent.WAITING_FOR_PERMISSION,
function (e) {
arviaChat.showNotification('Waiting for permission from the room agent');
console.log(e);
}
);
Dispatched when the room you are trying to join is full.
arviaChat.on(ArviaChatEvent.ROOM_FULL,
function (e) {
arviaChat.showNotification('This room is full');
console.log(e);
}
);
Dispatched after the getDeviceInfo is called and when the device info is generated.
arviaChat.getDeviceInfo();
// ArviaChatEvent.DEVICE_INFO event is dispatched when device info is generated.
arviaChat.on(ArviaChatEvent.DEVICE_INFO,
function (e) {
console.log(e);
}
);
Dispatched after the getDeviceInfo is called and when the device info can not be generated.
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!');
}
);
Dispatched when the camera access granted.
arviaChat.on(ArviaChatEvent.LOCAL_STREAM,
function (e) {
arviaChat.showNotification('Got video stream from the camera.');
console.log(e);
}
);
Dispatched if the camera can not be accessed.
arviaChat.on(ArviaChatEvent.LOCAL_STREAM_ERROR,
function (e) {
arviaChat.showNotification('Can not access camera.');
console.log(e);
}
);
Dispatched when the screen access granted.
arviaChat.on(ArviaChatEvent.SCREEN_SHARE,
function (e) {
arviaChat.showNotification('Got screen display to share.');
console.log(e);
}
);
Dispatched if the screen can not be shared.
arviaChat.on(ArviaChatEvent.SCREEN_SHARE_ERROR,
function (e) {
arviaChat.showNotification('Can not get screen display.');
console.log(e);
}
);
Dispatched when a message is received.
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);
}
);
Dispatched when trying to connect.
arviaChat.on(ArviaChatEvent.CONNECTING,
function (e) {
arviaChat.showNotification('Please wait while connecting...');
}
);