Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created November 14, 2021 06:08
Show Gist options
  • Save hieptl/c23417d4968eef40b5c56bc8c8225ff0 to your computer and use it in GitHub Desktop.
Save hieptl/c23417d4968eef40b5c56bc8c8225ff0 to your computer and use it in GitHub Desktop.
Main.js - Server - Direct Call - Discord Clone
...
const startDirectCall = () => {
if (cometChat && selectedChannel && selectedChannelType === 2) {
const sessionID = selectedChannel.guid;
const audioOnly = false;
const defaultLayout = true;
const callSettings = new cometChat.CallSettingsBuilder()
.enableDefaultLayout(defaultLayout)
.setSessionID(sessionID)
.setIsAudioOnlyCall(audioOnly)
.build();
const callSceen = document.getElementById("call__screen");
callSceen.classList.add('call__screen--active');
cometChat.startCall(
callSettings,
document.getElementById("call__screen"),
new cometChat.OngoingCallListener({
onUserListUpdated: userList => {
},
onCallEnded: call => {
callSceen.classList.remove('call__screen--active');
setSelectedChannelType(null);
},
onError: error => {
callSceen.classList.remove('call__screen--active');
setSelectedChannelType(null);
},
onMediaDeviceListUpdated: deviceList => {
},
onUserMuted: (userMuted, userMutedBy) => {
},
onScreenShareStarted: () => {
},
onScreenShareStopped: () => {
}
})
);
}
};
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment