Skip to content

Commit f01ca45

Browse files
committed
Support role in conference sample
1 parent facdcf4 commit f01ca45

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

src/main/webapp/conference.html

+33-14
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,18 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
244244
var token = getUrlParameter("token");
245245
var publishStreamId = getUrlParameter("streamId");
246246
var playOnly = getUrlParameter("playOnly");
247-
var dcOnly = getUrlParameter("dcOnly");
248-
249247
if (playOnly == null) {
250-
playOnly = false;
248+
playOnly = false;
251249
}
252-
250+
251+
var dcOnly = getUrlParameter("dcOnly");
252+
253253
if (dcOnly == null) {
254254
dcOnly = false;
255255
}
256+
257+
var role = getUrlParameter("role");
258+
256259

257260
var roomId = getUrlParameter("roomId");
258261
var streamName = getUrlParameter("streamName");
@@ -405,21 +408,32 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
405408
function sendData() {
406409
try {
407410
var iceState = webRTCAdaptor.iceConnectionState(publishStreamId);
411+
var msg = $("#dataTextbox").val();
412+
var notEvent = { streamId: publishStreamId, eventType: "CHAT_MESSAGE", message: msg };
413+
408414
if (iceState != null && iceState != "failed" && iceState != "disconnected") {
409415

410-
var msg = $("#dataTextbox").val();
411-
var notEvent = { streamId: publishStreamId, eventType: "CHAT_MESSAGE", message: msg };
416+
412417

413418
webRTCAdaptor.sendData(publishStreamId, JSON.stringify(notEvent));
414419
$("#all-messages").append("Sent: " + msg + "<br>");
415420
$("#dataTextbox").val("");
416421
}
417422
else {
418-
$.notify("WebRTC playing is not active. Please click Start Playing first", {
419-
autoHideDelay: 5000,
420-
className: 'error',
421-
position: 'top center'
422-
});
423+
iceState = webRTCAdaptor.iceConnectionState(roomNameBox.value);
424+
if (iceState != null && iceState != "failed" && iceState != "disconnected")
425+
{
426+
webRTCAdaptor.sendData(roomNameBox.value, JSON.stringify(notEvent));
427+
$("#all-messages").append("Sent: " + msg + "<br>");
428+
$("#dataTextbox").val("");
429+
}
430+
else {
431+
$.notify("WebRTC playing is not active. Please click Start Playing first", {
432+
autoHideDelay: 5000,
433+
className: 'error',
434+
position: 'top center'
435+
});
436+
}
423437
}
424438
}
425439
catch (exception) {
@@ -504,8 +518,10 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
504518
publishStreamId = generateRandomString(12);
505519
}
506520

507-
publish(publishStreamId, token);
508-
webRTCAdaptor.play(roomNameBox.value, token, roomNameBox.value, [], subscriberId, subscriberCode);
521+
if (!playOnly) {
522+
publish(publishStreamId, token);
523+
}
524+
webRTCAdaptor.play(roomNameBox.value, token, roomNameBox.value, [], subscriberId, subscriberCode, null, role);
509525
}
510526

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

531547
}
532548

@@ -765,6 +781,9 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
765781
else if (info == "play_started") {
766782
isPlaying = true;
767783
isNoSreamExist = false;
784+
join_publish_button.disabled = true;
785+
stop_publish_button.disabled = false;
786+
768787
webRTCAdaptor.getBroadcastObject(roomNameBox.value);
769788
if (reconnecting) {
770789
playReconnected = true;

0 commit comments

Comments
 (0)