Skip to content

Commit de864c5

Browse files
committed
QBWEBSDK-187 one more time
1 parent 6f158e1 commit de864c5

File tree

6 files changed

+54
-31
lines changed

6 files changed

+54
-31
lines changed

js/modules/webrtc/qbWebRTCClient.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ WebRTCClient.prototype._onCallListener = function(userID, sessionID, extension)
135135
this.signalingProvider.sendMessage(userID, extension, SignalingConstants.SignalingType.REJECT);
136136
} else {
137137
var session = this.sessions[sessionID];
138+
138139
if(!session){
139140
session = this._createAndStoreSession(sessionID, extension.callerID, extension.opponentsIDs, extension.callType);
140141

@@ -154,15 +155,19 @@ WebRTCClient.prototype._onAcceptListener = function(userID, sessionID, extension
154155

155156
var session = this.sessions[sessionID];
156157

157-
if(session || (session.state === WebRTCSession.State.ACTIVE || session.state === WebRTCSession.State.NEW)){
158-
var extensionClone = JSON.parse(JSON.stringify(extension));
159-
this._cleanupExtension(extensionClone);
158+
if(session){
159+
if(session.state === WebRTCSession.State.ACTIVE ) {
160+
var extensionClone = JSON.parse(JSON.stringify(extension));
161+
this._cleanupExtension(extensionClone);
160162

161-
if (typeof this.onAcceptCallListener === 'function'){
162-
this.onAcceptCallListener(session, userID, extensionClone);
163-
}
163+
if (typeof this.onAcceptCallListener === 'function'){
164+
this.onAcceptCallListener(session, userID, extensionClone);
165+
}
164166

165-
session.processOnAccept(userID, extension);
167+
session.processOnAccept(userID, extension);
168+
} else {
169+
Helpers.traceWarning("Ignore 'onAccept', the session( " + sessionID + " ) has invalid state.");
170+
}
166171
}else{
167172
Helpers.traceError("Ignore 'onAccept', there is no information about session " + sessionID + " by some reason.");
168173
}
@@ -212,7 +217,11 @@ WebRTCClient.prototype._onIceCandidatesListener = function(userID, sessionID, ex
212217
var session = this.sessions[sessionID];
213218

214219
if(session){
215-
session.processOnIceCandidates(userID, extension);
220+
if(session.state === WebRTCSession.State.ACTIVE) {
221+
session.processOnIceCandidates(userID, extension);
222+
} else {
223+
Helpers.traceWarning('Ignore \'OnIceCandidates\', the session ( ' + sessionID + ' ) has invalid state.');
224+
}
216225
}else{
217226
Helpers.traceError("Ignore 'OnIceCandidates', there is no information about session " + sessionID + " by some reason.");
218227
}

js/modules/webrtc/qbWebRTCHelpers.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ WebRTCHelpers = {
2828
}
2929
},
3030

31+
traceWarning: function(text) {
32+
if (config.debug) {
33+
console.warn('[QBWebRTC]:', text);
34+
}
35+
},
36+
3137
traceError: function(text) {
3238
if (config.debug) {
3339
console.error('[QBWebRTC]:', text);

js/modules/webrtc/qbWebRTCSession.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,17 +444,17 @@ WebRTCSession.filter = function(id, filters) {
444444
//
445445

446446
WebRTCSession.prototype.processOnCall = function(callerID, extension) {
447-
var self = this;
447+
var self = this,
448+
oppIDs = self._uniqueOpponentsIDs();
448449

449-
this._clearWaitingOfferOrAnswerTimer();
450+
self._clearWaitingOfferOrAnswerTimer();
450451

451-
var oppIDs = this._uniqueOpponentsIDs();
452-
oppIDs.forEach(function(opID, i, arr) {
453-
454-
var peerConnection = self.peerConnections[opID];
455-
if(peerConnection){
452+
oppIDs.forEach(function(opID, i, arr) {
453+
var pConn = self.peerConnections[opID];
454+
455+
if(pConn){
456456
if(opID == callerID){
457-
peerConnection.updateRemoteSDP(extension.sdp);
457+
pConn.updateRemoteSDP(extension.sdp);
458458

459459
// The group call logic starts here
460460
if(callerID != self.initiatorID && self.state === WebRTCSession.State.ACTIVE){
@@ -479,7 +479,6 @@ WebRTCSession.prototype.processOnCall = function(callerID, extension) {
479479
}
480480
}
481481
});
482-
483482
};
484483

485484
WebRTCSession.prototype.processOnAccept = function(userID, extension) {

js/qbStrophe.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@ var Utils = require('./qbUtils');
1212
function Connection() {
1313
var protocol = config.chatProtocol.active === 1 ? config.chatProtocol.bosh : config.chatProtocol.websocket;
1414
var conn = new Strophe.Connection(protocol);
15+
1516
if (config.chatProtocol.active === 1) {
16-
conn.xmlInput = function(data) { if (data.childNodes[0]) {for (var i = 0, len = data.childNodes.length; i < len; i++) {
17-
Utils.QBLog('[QBChat]', 'RECV:', data.childNodes[i]);
18-
}} };
19-
conn.xmlOutput = function(data) { if (data.childNodes[0]) {for (var i = 0, len = data.childNodes.length; i < len; i++) {
20-
Utils.QBLog('[QBChat]', 'SENT:', data.childNodes[i]);
21-
}} };
17+
conn.xmlInput = function(data) {
18+
if (data.childNodes[0]) {
19+
for (var i = 0, len = data.childNodes.length; i < len; i++) {
20+
Utils.QBLog('[QBChat]', 'RECV:', data.childNodes[i]);
21+
}
22+
}
23+
};
24+
conn.xmlOutput = function(data) {
25+
if (data.childNodes[0]) {
26+
for (var i = 0, len = data.childNodes.length; i < len; i++) {
27+
Utils.QBLog('[QBChat]', 'SENT:', data.childNodes[i]);
28+
}
29+
}
30+
};
2231
} else {
2332
conn.xmlInput = function(data) {
2433
Utils.QBLog('[QBChat]', 'RECV:', data);

quickblox.min.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/webrtc/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
app.currentSession = QB.webrtc.createNewSession(Object.keys(app.callees), QB.webrtc.CallType.VIDEO);
245245

246246
app.currentSession.getUserMedia(mediaParams, function(err, stream) {
247-
if (err || stream.getAudioTracks().length || stream.getVideoTracks().length) {
247+
if (err || !stream.getAudioTracks().length || !stream.getVideoTracks().length) {
248248
ui.updateMsg({msg: 'device_not_found', obj: {name: app.caller.full_name}});
249249
app.currentSession.stop({});
250250
} else {

0 commit comments

Comments
 (0)