@@ -244,15 +244,18 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
244
244
var token = getUrlParameter ( "token" ) ;
245
245
var publishStreamId = getUrlParameter ( "streamId" ) ;
246
246
var playOnly = getUrlParameter ( "playOnly" ) ;
247
- var dcOnly = getUrlParameter ( "dcOnly" ) ;
248
-
249
247
if ( playOnly == null ) {
250
- playOnly = false ;
248
+ playOnly = false ;
251
249
}
252
-
250
+
251
+ var dcOnly = getUrlParameter ( "dcOnly" ) ;
252
+
253
253
if ( dcOnly == null ) {
254
254
dcOnly = false ;
255
255
}
256
+
257
+ var role = getUrlParameter ( "role" ) ;
258
+
256
259
257
260
var roomId = getUrlParameter ( "roomId" ) ;
258
261
var streamName = getUrlParameter ( "streamName" ) ;
@@ -405,21 +408,32 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
405
408
function sendData ( ) {
406
409
try {
407
410
var iceState = webRTCAdaptor . iceConnectionState ( publishStreamId ) ;
411
+ var msg = $ ( "#dataTextbox" ) . val ( ) ;
412
+ var notEvent = { streamId : publishStreamId , eventType : "CHAT_MESSAGE" , message : msg } ;
413
+
408
414
if ( iceState != null && iceState != "failed" && iceState != "disconnected" ) {
409
415
410
- var msg = $ ( "#dataTextbox" ) . val ( ) ;
411
- var notEvent = { streamId : publishStreamId , eventType : "CHAT_MESSAGE" , message : msg } ;
416
+
412
417
413
418
webRTCAdaptor . sendData ( publishStreamId , JSON . stringify ( notEvent ) ) ;
414
419
$ ( "#all-messages" ) . append ( "Sent: " + msg + "<br>" ) ;
415
420
$ ( "#dataTextbox" ) . val ( "" ) ;
416
421
}
417
422
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
+ }
423
437
}
424
438
}
425
439
catch ( exception ) {
@@ -504,8 +518,10 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
504
518
publishStreamId = generateRandomString ( 12 ) ;
505
519
}
506
520
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 ) ;
509
525
}
510
526
511
527
function leaveRoom ( ) {
@@ -526,7 +542,7 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
526
542
if ( streamName == null || streamName == 'undefined' || streamName == "" ) {
527
543
streamName = streamId ;
528
544
}
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 ) ;
530
546
531
547
}
532
548
@@ -765,6 +781,9 @@ <h3 class="col text-muted">WebRTC Multitrack Conference</h3>
765
781
else if ( info == "play_started" ) {
766
782
isPlaying = true ;
767
783
isNoSreamExist = false ;
784
+ join_publish_button . disabled = true ;
785
+ stop_publish_button . disabled = false ;
786
+
768
787
webRTCAdaptor . getBroadcastObject ( roomNameBox . value ) ;
769
788
if ( reconnecting ) {
770
789
playReconnected = true ;
0 commit comments