1- var session = OT . initSession ( sessionId ) ,
2- publisher = OT . initPublisher ( " publisher" ) ,
1+ var session = OT . initSession ( apiKey , sessionId ) ,
2+ publisher = OT . initPublisher ( ' publisher' ) ,
33 archiveID = null ;
44
5- session . connect ( apiKey , token , function ( err , info ) {
6- if ( err ) {
7- alert ( err . message || err ) ;
5+ session . connect ( token , function ( error , info ) {
6+ if ( error ) {
7+ console . error ( 'Failed to connect' , error ) ;
8+ } else {
9+ session . publish ( publisher , function ( error ) {
10+ if ( error ) {
11+ console . error ( 'Failed to publish' , error ) ;
12+ }
13+ } ) ;
814 }
9- session . publish ( publisher ) ;
1015} ) ;
1116
1217session . on ( 'streamCreated' , function ( event ) {
13- session . subscribe ( event . stream , "subscribers" , { insertMode : "append" } ) ;
18+ session . subscribe ( event . stream , 'subscribers' , {
19+ insertMode : 'append'
20+ } , function ( error ) {
21+ if ( error ) {
22+ console . error ( 'Failed to subscribe' , error ) ;
23+ }
24+ } ) ;
1425} ) ;
1526
1627session . on ( 'archiveStarted' , function ( event ) {
1728 archiveID = event . id ;
18- console . log ( " ARCHIVE STARTED" ) ;
19- $ ( " .start" ) . hide ( ) ;
20- $ ( " .stop" ) . show ( ) ;
29+ console . log ( ' ARCHIVE STARTED' ) ;
30+ $ ( ' .start' ) . hide ( ) ;
31+ $ ( ' .stop' ) . show ( ) ;
2132 disableForm ( ) ;
2233} ) ;
2334
2435session . on ( 'archiveStopped' , function ( event ) {
2536 archiveID = null ;
26- console . log ( " ARCHIVE STOPPED" ) ;
27- $ ( " .start" ) . show ( ) ;
28- $ ( " .stop" ) . hide ( ) ;
37+ console . log ( ' ARCHIVE STOPPED' ) ;
38+ $ ( ' .start' ) . show ( ) ;
39+ $ ( ' .stop' ) . hide ( ) ;
2940 enableForm ( ) ;
3041} ) ;
3142
3243$ ( document ) . ready ( function ( ) {
33- $ ( " .start" ) . click ( function ( event ) {
34- var options = $ ( " .archive-options" ) . serialize ( ) ;
44+ $ ( ' .start' ) . click ( function ( event ) {
45+ var options = $ ( ' .archive-options' ) . serialize ( ) ;
3546 disableForm ( ) ;
36- $ . post ( " /start" , options ) . fail ( enableForm ) ;
47+ $ . post ( ' /start' , options ) . fail ( enableForm ) ;
3748 } ) . show ( ) ;
38- $ ( " .stop" ) . click ( function ( event ) {
39- $ . get ( " stop/" + archiveID ) ;
49+ $ ( ' .stop' ) . click ( function ( event ) {
50+ $ . get ( ' stop/' + archiveID ) ;
4051 } ) . hide ( ) ;
4152} ) ;
4253
4354
4455function disableForm ( ) {
45- $ ( " .archive-options-fields" ) . attr ( 'disabled' , 'disabled' ) ;
56+ $ ( ' .archive-options-fields' ) . attr ( 'disabled' , 'disabled' ) ;
4657}
4758
4859function enableForm ( ) {
49- $ ( " .archive-options-fields" ) . removeAttr ( 'disabled' ) ;
50- }
60+ $ ( ' .archive-options-fields' ) . removeAttr ( 'disabled' ) ;
61+ }
0 commit comments