|
132 | 132 | ui.createUsers(QBUsers, ui.$usersList); |
133 | 133 | ui.$usersTitle.text(MESSAGES.title_login); |
134 | 134 |
|
135 | | - if(!params.withoutUpdMsg) { |
136 | | - ui.updateMsg({msg: 'login'}); |
| 135 | + if(!params.withoutUpdMsg || params.msg) { |
| 136 | + ui.updateMsg({msg: params.msg}); |
137 | 137 | } |
138 | 138 | } |
139 | 139 |
|
|
142 | 142 | */ |
143 | 143 | ui.setPositionFooter(); |
144 | 144 |
|
145 | | - initializeUI(); |
| 145 | + initializeUI({withoutUpdMsg: false, msg: 'login'}); |
146 | 146 |
|
147 | 147 | QB.init(QBApp.appId, QBApp.authKey, QBApp.authSecret, CONFIG); |
148 | 148 |
|
149 | 149 | /** |
150 | 150 | * EVENTS |
151 | 151 | */ |
152 | | - /** Choose caller */ |
153 | | - $(document).on('click', '.j-user', function() { |
| 152 | + /** Choose caller or callees */ |
| 153 | + $(document).on('click', '.j-user', function(e) { |
154 | 154 | var $el = $(this), |
155 | 155 | usersWithoutCaller = [], |
156 | 156 | user = {}, |
|
184 | 184 | if(err !== null) { |
185 | 185 | app.caller = {}; |
186 | 186 |
|
187 | | - ui.updateMsg( {msg: 'connect_error'} ); |
188 | | - |
189 | | - initializeUI({withoutUpdMsg: true}); |
190 | 187 | ui.setPositionFooter(); |
191 | 188 | ui.togglePreloadMain('hide'); |
192 | 189 | } else { |
|
247 | 244 | app.currentSession = QB.webrtc.createNewSession(Object.keys(app.callees), QB.webrtc.CallType.VIDEO); |
248 | 245 |
|
249 | 246 | app.currentSession.getUserMedia(mediaParams, function(err, stream) { |
250 | | - if (err) { |
| 247 | + if (err || !stream.getAudioTracks().length || !stream.getVideoTracks().length) { |
251 | 248 | ui.updateMsg({msg: 'device_not_found', obj: {name: app.caller.full_name}}); |
| 249 | + app.currentSession.stop({}); |
252 | 250 | } else { |
253 | 251 | app.currentSession.call({}, function(error) { |
254 | 252 | if(error) { |
|
333 | 331 | }); |
334 | 332 |
|
335 | 333 | ui.$callees.append(videoElems); |
| 334 | + ui.setPositionFooter(); |
336 | 335 | ui.updateMsg( {msg: 'during_call', obj: {name: app.caller.full_name}} ); |
337 | 336 |
|
338 | 337 | app.currentSession.accept({}); |
|
375 | 374 | classesName = [], |
376 | 375 | activeClass = []; |
377 | 376 |
|
378 | | - if( app.currentSession.peerConnections[userID].stream ) { |
| 377 | + if( app.currentSession.peerConnections[userID].stream && !_.isEmpty( $that.attr('src')) ) { |
379 | 378 | if( $that.hasClass('active') ) { |
380 | 379 | $that.removeClass('active'); |
381 | 380 |
|
|
436 | 435 | */ |
437 | 436 | QB.chat.onDisconnectedListener = function() { |
438 | 437 | console.log('onDisconnectedListener.'); |
439 | | - |
440 | | - var initUIParams = authorizationing ? {withoutUpdMsg: true} : {}; |
| 438 | + var initUIParams = authorizationing ? {withoutUpdMsg: false, msg: 'no_internet'} : {withoutUpdMsg: false, msg: 'login'}; |
441 | 439 |
|
442 | 440 | app.caller = {}; |
443 | 441 | app.callees = []; |
|
452 | 450 | $('.j-callee').remove(); |
453 | 451 |
|
454 | 452 | ui.setPositionFooter(); |
455 | | - |
456 | 453 | authorizationing = false; |
457 | 454 | }; |
458 | 455 |
|
|
465 | 462 |
|
466 | 463 | ui.showCallBtn(); |
467 | 464 |
|
468 | | - ui.updateMsg({msg: 'call_stop', obj: {name: app.caller.full_name}}); |
| 465 | + if(session.opponentsIDs.length > 1) { |
| 466 | + ui.updateMsg({msg: 'call_stop', obj: {name: app.caller.full_name}}); |
| 467 | + } |
469 | 468 |
|
470 | 469 | /** delete blob from myself video */ |
471 | 470 | document.getElementById('localVideo').src = ''; |
|
487 | 486 | console.log('Session: ' + session); |
488 | 487 | console.groupEnd(); |
489 | 488 |
|
| 489 | + var userInfo = _.findWhere(QBUsers, {id: +userId}); |
| 490 | + |
| 491 | + /** It's for p2p call */ |
| 492 | + if(session.opponentsIDs.length === 1) { |
| 493 | + ui.updateMsg({ |
| 494 | + msg: 'p2p_call_stop', |
| 495 | + obj: { |
| 496 | + name: userInfo.full_name, |
| 497 | + reason: 'not answered' |
| 498 | + } |
| 499 | + }); |
| 500 | + } |
| 501 | + |
| 502 | + /** It's for groups call */ |
490 | 503 | $('.j-callee_status_' + userId).text('No Answer'); |
491 | 504 | }; |
492 | 505 |
|
|
553 | 566 | console.log('Extension: ' + JSON.stringify(extension)); |
554 | 567 | console.groupEnd(); |
555 | 568 |
|
| 569 | + var userInfo = _.findWhere(QBUsers, {id: userId}); |
| 570 | + |
| 571 | + /** It's for p2p call */ |
| 572 | + if(session.opponentsIDs.length === 1) { |
| 573 | + ui.updateMsg({ |
| 574 | + msg: 'p2p_call_stop', |
| 575 | + obj: { |
| 576 | + name: userInfo.full_name, |
| 577 | + reason: 'rejected the call' |
| 578 | + } |
| 579 | + }); |
| 580 | + } |
| 581 | + |
| 582 | + /** It's for groups call */ |
556 | 583 | $('.j-callee_status_' + userId).text('Rejected'); |
557 | 584 | }; |
558 | 585 |
|
|
563 | 590 | console.log('Extension: ' + JSON.stringify(extension)); |
564 | 591 | console.groupEnd(); |
565 | 592 |
|
| 593 | + var userInfo = _.findWhere(QBUsers, {id: userId}); |
| 594 | + |
| 595 | + /** It's for p2p call */ |
| 596 | + if(session.opponentsIDs.length === 1) { |
| 597 | + ui.updateMsg({ |
| 598 | + msg: 'p2p_call_stop', |
| 599 | + obj: { |
| 600 | + name: userInfo.full_name, |
| 601 | + reason: 'hung up the call' |
| 602 | + } |
| 603 | + }); |
| 604 | + } |
| 605 | + |
| 606 | + /** It's for groups call */ |
566 | 607 | $('.j-callee_status_' + userId).text('Hung Up'); |
567 | 608 | }; |
568 | 609 |
|
|
624 | 665 |
|
625 | 666 | if(app.mainVideo === userID) { |
626 | 667 | $('#remote_video_' + userID).removeClass('active'); |
| 668 | + |
| 669 | + ui.changeFilter('#main_video', 'no'); |
| 670 | + app.currentSession.detachMediaStream('main_video'); |
| 671 | + app.mainVideo = 0; |
627 | 672 | } |
628 | 673 |
|
629 | 674 | if( !_.isEmpty(app.currentSession) ) { |
|
0 commit comments