1.0.0
Constructor for Arvia Chat.
(string)
ID of your arvia.chat project. You can find this in your project overview on your arvia.chat account.
ArviaChat
:
Arvia Chat instance
var arviaChat = new ArviaChat('5b4f145ac4dbc95dcf926a52');
Set user id.
(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.
string
:
userId The user id set by the setUserId method.
arviaChat.getUserId();
// returns '12345'
Set test user.
(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.
boolean
:
If true, this is a test user.
arviaChat.getTestUser();
// returns true
Set room name.
(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.
string
:
The room name set by the setRoomName method.
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')
Set dynamic room name.
(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.
string
:
The room name set by the setDynamicRoomName method.
arviaChat.getDynamicRoomName();
// returns 'my-room'
// If current room is not a dynamic room, this method returns empty string.
Get user name.
string
:
The user name set by the setUserName method
arviaChat.getUserName();
// returns 'John Smith'
Set user email.
(string)
User email that you can assign to your user
arviaChat.setUserEmail('name@example.com');
Get user email.
string
:
The user email set by the setUserEmail method
arviaChat.getUserEmail();
// returns 'ame@example.com'
Set user telephone number.
(string)
Telephone number that you can assign to your user
arviaChat.setUserTel('+1 (123) 456 78 90');
Get user telephone number.
string
:
The telephone number set by the setUserTel method
arviaChat.getUserTel();
// returns '+1 (123) 456 78 90'
Set user info.
(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.
string
:
User details set by the setUserDetails method
arviaChat.getUserDetails();
// returns 'Calling from San Jose. Interested in annual contracts. Requests more info about pricing'
Set user tags.
arviaChat.setUserTags(['Speaks-English', 'From-USA', '25-year-old']);
Get user tags.
Array<string>
:
The user tags set by the setUserTags method
arviaChat.getUserTags();
// returns ['Speaks-English', 'From-USA', '25-year-old']
Set authentication object.
(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.
object
:
The authentication object set by the setAuthentication method
arviaChat.getAuthentication();
// returns {token: awqwr7632s76xfew68rhb68hwf8et}
Get the number of users in the room.
number
:
The number of users in the room.
arviaChat.getUserCount();
// returns 2
Set visibility of the user names on videos.
(boolean)
If set to true, user names will be shown on videos. If set to false, user names on videos will be hidden.
arviaChat.setVideoUserNamesVisibility(true);
Get visibility status of the user names on videos.
boolean
:
The visibility status of the user names on videos set by the setVideoUserNamesVisibility method
arviaChat.getVideoUserNamesVisibility();
// returns true
Set local media buttons visibility status.
(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.
boolean
:
The local media buttons visibility status set by the setLocalMediaButtonsVisibility method
arviaChat.getLocalMediaButtonsVisibility();
// returns true
Set visibility status of remote users' media options buttons.
(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.
boolean
:
The visibility status of remote users' media options buttons set by the setRemoteMediaButtonsVisibility method
arviaChat.getRemoteMediaButtonsVisibility();
// returns true
Set visibility status of message box.
(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.
boolean
:
The visibility status of message box set by the setMessageBoxVisibility method.
arviaChat.getMessageBoxVisibility();
// returns true
Set visibility status of media message button.
(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.
boolean
:
The visibility status of media message button set by the setMediaMessageButtonVisibility method.
arviaChat.getMediaMessageButtonVisibility();
// returns true
Set visibility status of end call button.
(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.
boolean
:
The visibility status of end call button set by the setEndCallButtonVisibility method.
arviaChat.getEndCallButtonVisibility();
// returns true
Enable or disable default notifications which are sent by the SDK.
(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.
boolean
:
If returns true, default notifications are enabled. If returns false, default notifications are disabled.
arviaChat.getDefaultNotificationsEnabled();
// returns true
Get device info. Audio/video input and output sources.
object
:
Device info object which includes audio and video sources.
arviaChat.getDeviceInfo();
// ArviaChatEvent.DEVICE_INFO event is dispatched when device info is generated.
arviaChat.on(ArviaChatEvent.DEVICE_INFO,
function (e) {
console.log(e);
}
);
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 .
(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 .
(boolean | string)
:
false or Camera Id of the outgoing video stream source.
arviaChat.getCamera();
Toggles sharing screen start/stop.
arviaChat.toggleScreenSharing();
Disconnect and terminate the chat interface.
(any)
arviaChat.close();
Set user name.
(string)
Name that you can assign to your user
arviaChat.setUserName('John Smith');
Set the outgoing audio stream source device.
arviaChat.setMicrophone(true);
Set the outgoing video stream source device.
arviaChat.setCamera(true);
Start or stop sharing screen.
(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.
(string)
Text to display
(string)
Type of the notification ('base', 'success', 'error', 'info', 'warn')
arviaChat.showNotification('Please wait while connecting...');
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 when trying to connect.
arviaChat.on(ArviaChatEvent.CONNECTING,
function (e) {
arviaChat.showNotification('Please wait while connecting...');
}
);
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 connected.
arviaChat.on(ArviaChatEvent.CONNECT,
function (e) {
arviaChat.showNotification('Connected to room');
}
);
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 if the authentication fails.
arviaChat.on(ArviaChatEvent.AUTHENTICATION_ERROR,
function (e) {
arviaChat.showNotification('Authentication failed.');
console.log(e);
}
);