Skip to content

Commit

Permalink
Support role in conference sample
Browse files Browse the repository at this point in the history
  • Loading branch information
mekya committed Oct 13, 2024
1 parent facdcf4 commit f01ca45
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions src/main/webapp/conference.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,18 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
var token = getUrlParameter("token");
var publishStreamId = getUrlParameter("streamId");
var playOnly = getUrlParameter("playOnly");
var dcOnly = getUrlParameter("dcOnly");

if (playOnly == null) {
playOnly = false;
playOnly = false;
}


var dcOnly = getUrlParameter("dcOnly");

if (dcOnly == null) {
dcOnly = false;
}

var role = getUrlParameter("role");


var roomId = getUrlParameter("roomId");
var streamName = getUrlParameter("streamName");
Expand Down Expand Up @@ -405,21 +408,32 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
function sendData() {
try {
var iceState = webRTCAdaptor.iceConnectionState(publishStreamId);
var msg = $("#dataTextbox").val();
var notEvent = { streamId: publishStreamId, eventType: "CHAT_MESSAGE", message: msg };

if (iceState != null && iceState != "failed" && iceState != "disconnected") {

var msg = $("#dataTextbox").val();
var notEvent = { streamId: publishStreamId, eventType: "CHAT_MESSAGE", message: msg };


webRTCAdaptor.sendData(publishStreamId, JSON.stringify(notEvent));
$("#all-messages").append("Sent: " + msg + "<br>");
$("#dataTextbox").val("");
}
else {
$.notify("WebRTC playing is not active. Please click Start Playing first", {
autoHideDelay: 5000,
className: 'error',
position: 'top center'
});
iceState = webRTCAdaptor.iceConnectionState(roomNameBox.value);
if (iceState != null && iceState != "failed" && iceState != "disconnected")
{
webRTCAdaptor.sendData(roomNameBox.value, JSON.stringify(notEvent));
$("#all-messages").append("Sent: " + msg + "<br>");
$("#dataTextbox").val("");
}
else {
$.notify("WebRTC playing is not active. Please click Start Playing first", {
autoHideDelay: 5000,
className: 'error',
position: 'top center'
});
}
}
}
catch (exception) {
Expand Down Expand Up @@ -504,8 +518,10 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
publishStreamId = generateRandomString(12);
}

publish(publishStreamId, token);
webRTCAdaptor.play(roomNameBox.value, token, roomNameBox.value, [], subscriberId, subscriberCode);
if (!playOnly) {
publish(publishStreamId, token);
}
webRTCAdaptor.play(roomNameBox.value, token, roomNameBox.value, [], subscriberId, subscriberCode, null, role);
}

function leaveRoom() {
Expand All @@ -526,7 +542,7 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
if (streamName == null || streamName == 'undefined' || streamName == "") {
streamName = streamId;
}
webRTCAdaptor.publish(publishStreamId, token, subscriberId, subscriberCode, streamName, roomNameBox.value, JSON.stringify(metadata));
webRTCAdaptor.publish(publishStreamId, token, subscriberId, subscriberCode, streamName, roomNameBox.value, JSON.stringify(metadata), role);

}

Expand Down Expand Up @@ -765,6 +781,9 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
else if (info == "play_started") {
isPlaying = true;
isNoSreamExist = false;
join_publish_button.disabled = true;
stop_publish_button.disabled = false;

webRTCAdaptor.getBroadcastObject(roomNameBox.value);
if (reconnecting) {
playReconnected = true;
Expand Down

0 comments on commit f01ca45

Please sign in to comment.