当前位置: 动力学知识库 > 问答 > 编程问答 >

QuickBlox JavaScript SDK: No incoming Call

问题描述:

I'm developing an application (JavaScript) using QuickBlox. I was able to initialize QB, connect to chat session and place call successfully but onCallListener wasn't getting any incoming call.

My complete code is given bellow:

<script type="text/javascript">

$(document).ready(function () {

var mediaParams = {

audio: true,

video: true,

options: {

muted: true,

mirror: false

},

elemId: 'LocalVideo'

};

var CONFIG = {

webrtc: {

answerTimeInterval: 60, // Max answer time after that the 'QB.webrtc.onUserNotAnswerListener' callback will be fired.

dialingTimeInterval: 5, // The interval between call requests produced by session.call(extension)

disconnectTimeInterval: 30 // If an opponent lost a connection then after this time the caller will now about it via 'QB.webrtc.onSessionConnectionStateChangedListener' callback.

}

};

var call = $('#callingSignal')[0];

var ring = $('#ringtoneSignal')[0];

var btnCall = $("#btn-Call");

btnCall.prop("value", "Initialing");

btnCall.prop('disabled', true);

QB.init(app_id, 'api_key', 'api_secret', CONFIG);

QB.createSession({

login: 'username',

password: 'password'

}, function (err, res) {

if (res) {

QB.chat.connect({

userId: 12345678,

password: 'password'

}, function (err, roster) {

if (err) {

console.log("Chat connection error: " + err);

return false;

} else {

console.log("QB is ready");

btnCall.prop('disabled', false);

btnCall.prop('enabled', true);

btnCall.prop("value", "Call Now");

console.log(QB);

}

});

} else {

console.log("QB session creation error: " + err);

return false;

}

});

btnCall.click(function (e) {

e.preventDefault();

var searchIDs = $(".callee input:checkbox:checked").map(function () {

return parseInt($(this).val());

}).get();

console.log(searchIDs.length);

if (searchIDs.length < 1) {

console.log("Caller ID wasn't provided");

return false;

}

console.log("Calling: " + searchIDs);

var session = QB.webrtc.createNewSession(searchIDs, QB.webrtc.CallType.VIDEO);

session.getUserMedia(mediaParams, function (err, stream) {

if (err) {

alert("Without media access, it's not possible to continue calling: " + err);

window.location = "/";

} else {

session.call(searchIDs, function (error) {

if (error) {

console.log("Call establishment error: " + error);

} else {

btnCall.prop("value", "Calling");

btnCall.prop('disabled', true);

call.play();

}

});

}

});

});

QB.webrtc.onCallListener = function onCallListener(session, extension) {

console.log("Incoming Call");

console.log(session);

console.log(extension);

session.accept(extension);

};

QB.webrtc.onUserNotAnswerListener = function onUserNotAnswerListener(session, userId) {

call.pause();

var naemsg = "Sorry, <strong>" + Databases[userId] + "</strong> did't pick the call!";

showErrorModal(naemsg);

btnCall.prop('disabled', false);

btnCall.prop('enabled', true);

btnCall.prop("value", "Call Now");

};

QB.webrtc.onAcceptCallListener = function onAcceptCallListener(session, userId, extension) {

console.log(Databases[userId] + " Call answered")

};

QB.webrtc.onRemoteStreamListener = function onRemoteStreamListener(session, userID, remoteStream) {

// attach the remote stream to DOM element

session.attachMediaStream('MainVideo', remoteStream);

$("#MainVideo").prop("controls", true);

btnCall.prop('disabled', false);

btnCall.prop('enabled', true);

btnCall.prop("value", "Call Now");

};

QB.chat.onDisconnectedListener = function onDisconnectedListener() {

showErrorModal("Session disconnected. Please reload the page.");

btnCall.prop('disabled', false);

btnCall.prop('enabled', true);

btnCall.prop("value", "Call Now");

};

QB.webrtc.onSessionCloseListener = function onSessionCloseListener(session) {

console.log('onSessionCloseListener: ' + session);

};

QB.webrtc.onUpdateCallListener = function onUpdateCallListener(session, userId, extension) {

console.log("Call updater")

};

QB.webrtc.onRejectCallListener = function onRejectCallListener(session, userId, extension) {

showErrorModal("Sorry, <strong>" + Databases[userId] + "</strong> rejected your call!");

};

QB.webrtc.onStopCallListener = function onStopCallListener(session, userId, extension) {

console.log("Called Stopped");

btnCall.prop('disabled', false);

btnCall.prop('enabled', true);

btnCall.prop("value", "Call Now");

};

QB.webrtc.onSessionConnectionStateChangedListener = function onSessionConnectionStateChangedListener(session, userID, connectionState) {

console.group('onSessionConnectionStateChangedListener.');

console.log('UserID: ' + userID);

console.log('Session: ' + session);

console.log('Сonnection state: ' + connectionState);

console.groupEnd();

if (connectionState === QB.webrtc.SessionConnectionState.CONNECTING) {

console.log("Connecting")

}

if (connectionState === QB.webrtc.SessionConnectionState.CONNECTED) {

console.log("Connected")

}

if (connectionState === QB.webrtc.SessionConnectionState.COMPLETED) {

console.log("Completed")

}

if (connectionState === QB.webrtc.SessionConnectionState.DISCONNECTED) {

console.log("Discinnected")

}

if (connectionState === QB.webrtc.SessionConnectionState.CLOSED) {

console.log("Closed")

}

};

});

function showErrorModal(errorMsg) {

var errorModal = $('.errorModal');

$('.errorModalMsg').html(errorMsg);

errorModal.modal();

}

</script>

I wasn't get such error message after celling in console window. But other logged in user didn't receive any call

Console log is here:

[QBWebRTC]: RTCPeerConnection init. userID: 12345678, sessionID: 42681376-cdd0-4d7e-b260-a5dab33441c3, type: offer

quickblox.min.js:3 [QBWebRTC]: getAndSetLocalSessionDescription success

quickblox.min.js:3 [QBWebRTC]: _startDialingTimer, dialingTimeInterval: 5000

quickblox.min.js:3 [QBWebRTC]: _dialingCallback, answerTimeInterval: 0

quickblox.min.js:6 Uncaught InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('0') is not a valid name.

...

...

...

[QBWebRTC]: _dialingCallback, answerTimeInterval: 60000

quickblox.min.js:3 [QBWebRTC]: _clearDialingTimer

quickblox.min.js:3 [QBWebRTC]: Answer timeout callback for session 42681376-cdd0-4d7e-b260-a5dab33441c3 for user 10431702

quickblox.min.js:3 [QBWebRTC]: All peer connections closed: true

(index):244 onSessionCloseListener: ID: 42681376-cdd0-4d7e-b260-a5dab33441c3, initiatorID: 12345678, opponentsIDs: 12345678, state: 2, callType: 1

quickblox.min.js:3 [QBWebRTC]: onIceConnectionStateCallback: closed

(index):263 onSessionConnectionStateChangedListener.

(index):264 UserID: 12345678

(index):265 Session: ID: 42681376-cdd0-4d7e-b260-a5dab33441c3, initiatorID: 10311194, opponentsIDs: 10431702, state: 5, callType: 1

(index):266 Сonnection state: 5

(index):287 Closed

Only error message I got was

quickblox.min.js:6 Uncaught InvalidCharacterError: Failed to execute

'createElement' on 'Document': The tag name provided ('0') is not a

valid name..

I couldn't get why onCallListener didn't get any response in Callee end.

Any idea how to fix the issue?

分享给朋友:
您可能感兴趣的文章:
随机阅读: