You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.2 KiB
57 lines
1.2 KiB
/* eslint-disable require-jsdoc */
|
|
|
|
// initialize userId/roomId
|
|
$('#userId').val('user_' + parseInt(Math.random() * 100000000));
|
|
$('#roomId').val('889988');
|
|
|
|
let rtc = null;
|
|
|
|
$('#join').on('click', function (e) {
|
|
e.preventDefault();
|
|
if (rtc) return;
|
|
const userId = $('#userId').val();
|
|
const roomId = $('#roomId').val();
|
|
const config = genTestUserSig(userId);
|
|
rtc = new RtcClient({
|
|
userId,
|
|
roomId,
|
|
sdkAppId: config.sdkAppId,
|
|
userSig: config.userSig
|
|
});
|
|
rtc.join();
|
|
});
|
|
|
|
$('#publish').on('click', function (e) {
|
|
e.preventDefault();
|
|
if (!rtc) {
|
|
Toast.error('请先加入房间!');
|
|
return;
|
|
}
|
|
rtc.publish();
|
|
});
|
|
|
|
$('#unpublish').on('click', function (e) {
|
|
e.preventDefault();
|
|
if (!rtc) {
|
|
Toast.error('请先加入房间!');
|
|
return;
|
|
}
|
|
rtc.unpublish();
|
|
});
|
|
|
|
$('#leave').on('click', function (e) {
|
|
e.preventDefault();
|
|
if (!rtc) {
|
|
Toast.error('请先加入房间!');
|
|
return;
|
|
}
|
|
rtc.leave();
|
|
rtc = null;
|
|
});
|
|
|
|
$('#settings').on('click', function (e) {
|
|
e.preventDefault();
|
|
$('#settings').toggleClass('btn-raised');
|
|
$('#setting-collapse').collapse();
|
|
});
|