I m using web sdk. and every student can join as a HOST . LOL scenario.
Please help me to resolve this case. here is JS script code
<script>
window.addEventListener('DOMContentLoaded', function (event) {
console.log('DOM fully loaded and parsed');
websdkready();
});
function websdkready() {
var testTool = window.testTool;
// get meeting args from url
var tmpArgs = testTool.parseQuery();
console.log(tmpArgs)
var meetingConfig = {
apiKey: "{{$apiKey}}",
meetingNumber: "{{$zoomMeetingId}}",
userName: "{{$userName}}",
passWord: "{{$meetingPassword}}",
leaveUrl: "/index.html",
role: "{{$meetingRole}}",
userEmail: "{{$userEmail}}",
lang: "{{$meetingLang}}",
signature: "{{$signature}}",
china: "{{$meetingChina}}",
};
// a tool use debug mobile device
if (testTool.isMobileDevice()) {
vConsole = new beginJoinVConsole();
}
if (meetingConfig.china)
ZoomMtg.setZoomJSLib("https://jssdk.zoomus.cn/1.9.1/lib", "/av"); // china cdn option
ZoomMtg.preLoadWasm();
ZoomMtg.prepareJssdk();
function beginJoin(signature) {
ZoomMtg.init({
leaveUrl: meetingConfig.leaveUrl,
webEndpoint: meetingConfig.webEndpoint,
disableInvite: true,
disableCallOut: true,
debug: true,
isSupportAV: true,
isSupportChat: false,
meetingInfo: [],
success: function () {
ZoomMtg.i18n.load(meetingConfig.lang);
ZoomMtg.i18n.reload(meetingConfig.lang);
console.log(meetingConfig);
ZoomMtg.join({
meetingNumber: meetingConfig.meetingNumber,
userName: meetingConfig.userName,
userEmail: meetingConfig.userEmail,
signature: signature,
apiKey: meetingConfig.apiKey,
passWord: meetingConfig.passWord,
success: function (res) {
console.log("join meeting success");
console.log(res);
},
error: function (res) {
console.log(res);
},
});
},
error: function (res) {
console.log(res);
},
});
ZoomMtg.inMeetingServiceListener('onUserJoin', function (data) {
console.log("ON USER JOIN");
console.log('inMeetingServiceListener onUserJoin', data);
var userId = data.userId;
var userEmail = data.userName;
var isHost = data.isHost;
var zoomMeetingId = "{{$zoomMeetingId}}";
if (!isHost) {
var isValidAuthorizedUser = checkAuthorizedUser(userEmail); //Default : True
var isValidCourseEnrollment = checkValidEnrollment(zoomMeetingId, userEmail); //Default : True
var hasUnpaidInvoices = checkHasUnpaidInvoices(userEmail); //Default : False
console.log("has Unpaid Invoices : " + hasUnpaidInvoices);
console.log("Is Valid Course Enrollment : " + isValidCourseEnrollment);
console.log("Is Valid Authorized User : " + isValidAuthorizedUser)
console.log("Condition :" + (isValidAuthorizedUser === "false" || isValidCourseEnrollment === "false" || hasUnpaidInvoices === "true"));
if (isValidAuthorizedUser === "false" || isValidCourseEnrollment === "false" || hasUnpaidInvoices === "true") {
console.log("Removed Participant");
//Remove Participant User
ZoomMtg.expel({
userId: userId
});
}
}
});
// Check Authorization of User
function checkAuthorizedUser(userEmail) {
var isAuthorizedUser = "";
$.ajax({
type: "GET",
async: false,
url: "{{ url('meeting/web/checkauthorizeduser') }}/",
data: {
'userEmail': userEmail,
'_token': '{{csrf_token()}}',
},
dataType: 'HTML',
success: function (response) {
isAuthorizedUser = response;
}
});
return isAuthorizedUser;
}
// Check Validation of Enrollment
function checkValidEnrollment(zoomMeetingId, userEmail) {
var isValidEnrollment = "";
$.ajax({
type: "GET",
async: false,
url: "{{ url('meeting/web/checkvalidcourseenrollment') }}/",
data: {
'zoomMeetingId': zoomMeetingId,
'userEmail': userEmail,
'_token': '{{csrf_token()}}',
},
dataType: 'HTML',
success: function (response) {
isValidEnrollment = response;
}
});
return isValidEnrollment;
}
//Get Unpaid Invoices
function checkHasUnpaidInvoices(userEmail) {
var isEmptyUnpaidInvoices = "";
$.ajax({
type: "GET",
async: false,
url: "{{ url('meeting/web/hasunapidinvoices') }}/",
data: {
'userEmail': userEmail,
'_token': '{{csrf_token()}}',
},
dataType: 'HTML',
success: function (response) {
isEmptyUnpaidInvoices = response;
}
});
return isEmptyUnpaidInvoices;
}
}
beginJoin(meetingConfig.signature);
};